dew/src/main/java/org/apidesign/bck2brwsr/dew/BaseFileObject.java
changeset 1372 cc58b30499e5
parent 1371 fd2d4ca28bd3
child 1373 c4e57ec5f0df
     1.1 --- a/dew/src/main/java/org/apidesign/bck2brwsr/dew/BaseFileObject.java	Sat Oct 12 09:05:08 2013 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,110 +0,0 @@
     1.4 -/**
     1.5 - * Back 2 Browser Bytecode Translator
     1.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     1.7 - *
     1.8 - * This program is free software: you can redistribute it and/or modify
     1.9 - * it under the terms of the GNU General Public License as published by
    1.10 - * the Free Software Foundation, version 2 of the License.
    1.11 - *
    1.12 - * This program is distributed in the hope that it will be useful,
    1.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.15 - * GNU General Public License for more details.
    1.16 - *
    1.17 - * You should have received a copy of the GNU General Public License
    1.18 - * along with this program. Look for COPYING file in the top folder.
    1.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
    1.20 - */
    1.21 -
    1.22 -package org.apidesign.bck2brwsr.dew;
    1.23 -
    1.24 -import java.net.URI;
    1.25 -import javax.lang.model.element.Modifier;
    1.26 -import javax.lang.model.element.NestingKind;
    1.27 -
    1.28 -/**
    1.29 - *
    1.30 - * @author Tomas Zezula
    1.31 - */
    1.32 -public abstract class BaseFileObject implements InferableJavaFileObject {
    1.33 -
    1.34 -    protected final String path;
    1.35 -    protected final Kind kind;
    1.36 -
    1.37 -    BaseFileObject(
    1.38 -        String path,
    1.39 -        Kind kind) {
    1.40 -        if (!path.startsWith("/")) {    //NOI18N
    1.41 -            throw new IllegalArgumentException();
    1.42 -        }
    1.43 -        this.path = path;
    1.44 -        this.kind = kind;
    1.45 -    }
    1.46 -
    1.47 -
    1.48 -    @Override
    1.49 -    public String infer() {
    1.50 -        return ClassLoaderFileManager.convertResourceToFQN(path);
    1.51 -    }
    1.52 -
    1.53 -    @Override
    1.54 -    public Kind getKind() {
    1.55 -        return kind;
    1.56 -    }
    1.57 -
    1.58 -    @Override
    1.59 -    public boolean isNameCompatible(String simpleName, Kind kind) {
    1.60 -        return this.kind == kind &&
    1.61 -        getSimpleName(path).equals(simpleName);
    1.62 -    }
    1.63 -
    1.64 -    @Override
    1.65 -    public NestingKind getNestingKind() {
    1.66 -        return null;
    1.67 -    }
    1.68 -
    1.69 -    @Override
    1.70 -    public Modifier getAccessLevel() {
    1.71 -        return null;
    1.72 -    }
    1.73 -
    1.74 -    @Override
    1.75 -    public URI toUri() {
    1.76 -        return URI.create(escape(path));
    1.77 -    }
    1.78 -
    1.79 -    @Override
    1.80 -    public String getName() {
    1.81 -        return path;
    1.82 -    }
    1.83 -
    1.84 -
    1.85 -
    1.86 -    protected static String getSimpleName(String path) {
    1.87 -        int slashIndex = path.lastIndexOf('/');
    1.88 -        assert slashIndex >= 0;
    1.89 -        return (slashIndex + 1 < path.length()) ?
    1.90 -            path.substring(slashIndex + 1) :
    1.91 -            ""; //NOI18N
    1.92 -    }
    1.93 -
    1.94 -    protected static Kind getKind(final String path) {
    1.95 -        final String simpleName = getSimpleName(path);
    1.96 -        final int dotIndex = simpleName.lastIndexOf('.'); //NOI18N
    1.97 -        final String ext = dotIndex > 0 ?
    1.98 -            simpleName.substring(dotIndex) :
    1.99 -            "";
   1.100 -        for (Kind k : Kind.values()) {
   1.101 -            if (k.extension.equals(ext)) {
   1.102 -                return k;
   1.103 -            }
   1.104 -        }
   1.105 -        return Kind.OTHER;
   1.106 -    }
   1.107 -
   1.108 -    private String escape(String path) {
   1.109 -        return path;
   1.110 -    }
   1.111 -
   1.112 -
   1.113 -}