001: /**
002: * InstantJ
003: *
004: * Copyright (C) 2002 Nils Meier
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: */package instantj.compile.sun;
017:
018: import instantj.compile.Source;
019: import java.io.IOException;
020: import java.io.InputStream;
021: import java.util.Date;
022:
023: /**
024: * Internal representation of a Sun-ClassFile. Sun's compiler can
025: * compile this thing even though there is no real physical
026: * representation anyware on disk
027: *
028: * @author <A href="mailto:nils@meiers.net">Nils Meier</A>
029: */
030: class InstantClassFile extends sun.tools.java.ClassFile {
031:
032: /** our wrapped source */
033: private Source source;
034:
035: /**
036: * Constructor
037: */
038: public InstantClassFile(Source source) {
039: super (null);
040: this .source = source;
041: }
042:
043: /**
044: * Our source always exists :)
045: */
046: public boolean exists() {
047: return true;
048: }
049:
050: /**
051: * AbsoluteName = Name
052: */
053: public String getAbsoluteName() {
054: return getName();
055: }
056:
057: /**
058: * Reading anyone? Read from our source as a ByteStream
059: */
060: public InputStream getInputStream() throws IOException {
061: return source.getInputStream();
062: }
063:
064: /**
065: * Source's name + ".java" = Name
066: */
067: public String getName() {
068: return source.getName() + ".java";
069: }
070:
071: /**
072: * The path to our source = Name
073: */
074: public String getPath() {
075: return source.getName();
076: }
077:
078: /**
079: * No way!
080: */
081: public boolean isDirectory() {
082: return false;
083: }
084:
085: /**
086: * No zipping here!
087: */
088: public boolean isZipped() {
089: return false;
090: }
091:
092: /**
093: * Always up to date :)
094: */
095: public long lastModified() {
096: return new Date().getTime();
097: }
098:
099: /**
100: * Ignored
101: */
102: public long length() {
103: return 0;
104: }
105:
106: /**
107: * Informative
108: */
109: public String toString() {
110: return getName();
111: }
112:
113: }
|