InstantClassFile.java :  » Scripting » InstantJ » instantj » compile » sun » Java Open Source

Java Open Source » Scripting » InstantJ 
InstantJ » instantj » compile » sun » InstantClassFile.java
/**
 * InstantJ
 * 
 * Copyright (C) 2002 Nils Meier
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 */
package instantj.compile.sun;

import instantj.compile.Source;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;

/**
 * Internal representation of a Sun-ClassFile. Sun's compiler can 
 * compile this thing even though there is no real physical 
 * representation anyware on disk
 *
 * @author <A href="mailto:nils@meiers.net">Nils Meier</A>
 */
class InstantClassFile extends sun.tools.java.ClassFile {

  /** our wrapped source */
  private Source source;

  /**
   * Constructor
   */
  public InstantClassFile(Source source) {
    super(null);
    this.source=source;
  }

  /**
   * Our source always exists :)
   */
  public boolean exists() {
    return true;
  }
  
  /**
   * AbsoluteName = Name
   */
  public String getAbsoluteName() {
    return getName();
  }
  
  /**
   * Reading anyone? Read from our source as a ByteStream
   */
  public InputStream getInputStream() throws IOException {
    return source.getInputStream();
  }
  
  /**
   * Source's name + ".java" = Name
   */
  public String getName() {
    return source.getName()+".java";
  }
  
  /**
   * The path to our source = Name
   */
  public String getPath() {
    return source.getName();
  }
  
  /**
   * No way!
   */
  public boolean isDirectory() {
    return false;
  }
  
  /**
   * No zipping here!
   */
  public boolean isZipped() {
    return false;
  }
  
  /**
   * Always up to date :)
   */
  public long lastModified() {
    return new Date().getTime();
  }
  
  /**
   * Ignored
   */
  public long length() {
    return 0;
  }
  
  /**
   * Informative 
   */
  public String toString() {
    return getName();
  }
  
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.