001/****************************************************************************
002 * Copyright/Copyleft:
003 *
004 * For this source the LGPL Lesser General Public License,
005 * published by the Free Software Foundation is valid.
006 * It means:
007 * 1) You can use this source without any restriction for any desired purpose.
008 * 2) You can redistribute copies of this source to everybody.
009 * 3) Every user of this source, also the user of redistribute copies
010 *    with or without payment, must accept this license for further using.
011 * 4) But the LPGL is not appropriate for a whole software product,
012 *    if this source is only a part of them. It means, the user
013 *    must publish this part of source,
014 *    but don't need to publish the whole source of the own product.
015 * 5) You can study and modify (improve) this source
016 *    for own using or for redistribution, but you have to license the
017 *    modified sources likewise under this LGPL Lesser General Public License.
018 *    You mustn't delete this Copyright/Copyleft inscription in this source file.
019 *
020 * @author Hartmut Schorrig: hartmut.schorrig@vishia.de, www.vishia.org
021 * @version 0.93 2011-01-05  (year-month-day)
022 *******************************************************************************/ 
023package org.vishia.java2C;
024
025import java.util.LinkedList;
026import java.util.List;
027import java.util.Map;
028import java.util.TreeMap;
029
030/**This class contains all information of available java sources while translation process.
031 * It is created only one time for {@link Java2C_Main#javaSources}. 
032 * But this class contains the interface {@link ClassDataOrJavaSrcFile}, 
033 * which is implemented in {@link JavaSrcTreeFile} and {@link JavaSrcTreePkg}.
034 */
035public class JavaSources
036{
037  
038  public interface ClassDataOrJavaSrcFile
039  {
040    /**Returns the ClassData of the instance, or <code>null</code>. If the instance is of type ClassData,
041     * it returns the instance itself. If the instance is of type {@link JavaSrcTreeFile}, it returns
042     * the associated ClassData, if the file is translated yet or the stc-file is read already.
043     * If the file isn't translated, it returns null.*/
044    ClassData getClassData();
045    
046    /**Returns the instance if it is a JavaSrcTreeFile, else <code>null</code>. */
047    JavaSrcTreeFile getJavaSrc();
048  
049    /**Returns the instance if it is a JavaSrcTreePkg, else <code>null</code>. */
050    JavaSrcTreePkg getJavaPkg();
051  
052    /**Returns the name of the class or package. It is the public class in a file.
053     */
054    String getTypeName();
055    
056    
057    /**Returns the identifier of classes or packages, which are available in the implementing
058     * package, file or class.
059     * 
060     * @param sName Name of the element. Especially if it is a {@link JavaSrcTreeFile},
061     *        it may be the name of the public class or another class in the file. 
062     * @return Especially list of all types in the element. If it is a package, 
063     *         the types may be the files in the package or sub-packages. 
064     */
065    LocalIdents getLocalIdents(String sName);
066   
067    /**Returns the informations to find out where the C-file is found and which pre/suffix are valid.
068     * @return null if there are not such informations. That is especially for super-paths.
069     */
070    ConfigSrcPathPkg_ifc.Set getReplaceCinfo();
071
072    /**Returns true if the translation from Java is set. 
073     * It doesn't mean that it should be translated any time, the necessity of translation
074     * depends on the time stamps of Java- and C-files. But the Java-File have to be existing.
075     * @return false if always the stc-File is to be read, or it is a ClassData.
076     */
077    boolean isToTranslate();
078    
079    void setClassData(ClassData data);
080    
081}
082  
083  
084  /**Tree of all found java-files in the source path, independent of their usage as source for translation.
085   * The files at the leafs of the tree {@link JavaSrcTreeFile} contains the information, 
086   * whether they should translate.
087   * <br>
088   * This JavaFolder is the root folder, without name and package designation. 
089   * It contains the first level package instances. 
090   */
091  public final JavaSrcTreePkg javaSrcTree = new JavaSrcTreePkg(null, "", "", null);
092
093   /**All files to translate.
094   */
095  final List<JavaSrcTreeFile> listJavaSrcFilesToTranslate = new LinkedList<JavaSrcTreeFile>();
096
097  /**Index (Map) of all known packages to fast search via its name. 
098   * The key contains the complete package path separated and ending with <code>/</code>.
099   */
100  final Map<String, JavaSrcTreePkg> indexJavaSrcPkgs = new TreeMap<String, JavaSrcTreePkg>();
101  
102  public JavaSources()
103  {
104        
105  }
106  
107  
108}