org.vishia.java2C
Class JavaSrcTreePkg

java.lang.Object
  extended by org.vishia.java2C.JavaSrcTreePkg
All Implemented Interfaces:
JavaSources.ClassDataOrJavaSrcFile, SortedTree<JavaSrcTreePkg>

public class JavaSrcTreePkg
extends java.lang.Object
implements SortedTree<JavaSrcTreePkg>, JavaSources.ClassDataOrJavaSrcFile

Representation of an existing Folder in the Java pkg tree.


Field Summary
private  java.util.List<JavaSources.ClassDataOrJavaSrcFile> javaPublicClasses
          Same content as #javaFiles, but the key is the class name.
private  JavaSrcTreePkg parent
          The parent pkg, it is only to see in debug and reports.
private  boolean pkgHasFiles
          Set to true if #setFileJava(String, File, String, String, String, boolean) is called the first time.
private  LocalIdents pkgIdents
          Index of all sub-packages and classes available in the package, package privates too.
private  ConfigSrcPathPkg_ifc.Set replaceCinfo
          If this info is found, a stc-file is determined for the package to replace structure info instead given Java-files.
private  java.lang.String sPkgName
           
private  java.lang.String sPkgPath
           
private  java.util.TreeMap<java.lang.String,JavaSrcTreePkg> subPkgs
           
private  java.util.TreeMap<java.lang.String,JavaSrcTreeFile> XXXjavaFiles
          All file.java containing in this package.
 
Constructor Summary
JavaSrcTreePkg(JavaSrcTreePkg parent, java.lang.String pkgPath, java.lang.String pkgName, ConfigSrcPathPkg_ifc.Set replaceCinfo)
           
 
Method Summary
 JavaSrcTreePkg getChild(java.lang.String key)
          Searches the first child with given key from the given node this.
 ClassData getClassData()
          Returns the ClassData of the instance, or null.
 JavaSrcTreePkg getJavaPkg()
          Implements JavaSources.ClassDataOrJavaSrcFile.getJavaPkg()
 JavaSrcTreeFile getJavaSrc()
          Implements JavaSources.ClassDataOrJavaSrcFile.getJavaSrc()
 LocalIdents getLocalIdents(java.lang.String sPkgName)
          Returns the identifier of classes or packages, which are available in this package.
 JavaSrcTreePkg getOrAddPkg(java.lang.String pkgPath, java.lang.String pkgName, ConfigSrcPathPkg_ifc.Set replaceCinfo)
          returns the Instance, which represents the given package name.
 LocalIdents getPkgLevelIdents()
          gets the pkg-level-idents.
 java.lang.String getPkgPath()
           
 java.util.List<JavaSources.ClassDataOrJavaSrcFile> getPublicClasses()
           
 ConfigSrcPathPkg_ifc.Set getReplaceCinfo()
          Returns the informations to find out where the C-file is found and which pre/suffix are valid.
 java.lang.String getTypeName()
          Implements JavaSources.ClassDataOrJavaSrcFile.getTypeName()
 boolean isToTranslate()
          returns false because a package isn't to translate.
 java.util.Iterator<JavaSrcTreePkg> iterChildren()
          Returns an iterator through the list of all children of the node.
 java.util.Iterator<JavaSrcTreePkg> iterChildren(java.lang.String key)
          Returns an iterator through the list of all children with the given key.
 java.util.List<JavaSrcTreePkg> listChildren()
          Returns a List of all children of the node.
 java.util.List<JavaSrcTreePkg> listChildren(java.lang.String key)
          Returns a List of all children with the given key.
 void putClassType(ClassData data)
          Adds the given type info to the pkgIdents.
 void reportClasses(Report report)
           
 void setClassData(ClassData data)
           
 JavaSources.ClassDataOrJavaSrcFile setFileJava(java.lang.String javaSrcPath, java.io.File fileJava, java.lang.String sFileNameJava, ConfigSrcPathPkg_ifc.Set info, java.lang.String prefixCFile, java.lang.String suffixCFile, java.lang.String prefixNames, java.lang.String suffixNames, java.lang.String stcPath, boolean translateToC)
          Registers the first occurrence of a found Java file or set the ConfigSrcPathPkg_ifc.Set for an existing file without replaceCinfo
 java.lang.String toString()
           
 void xxxaddStdTypes(LocalIdents types)
          Adds all standard types to the package.
 java.util.TreeMap<java.lang.String,JavaSrcTreeFile> XXXgetJavaFiles()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sPkgPath

private final java.lang.String sPkgPath

sPkgName

private final java.lang.String sPkgName

parent

private final JavaSrcTreePkg parent
The parent pkg, it is only to see in debug and reports.


subPkgs

private java.util.TreeMap<java.lang.String,JavaSrcTreePkg> subPkgs

XXXjavaFiles

private final java.util.TreeMap<java.lang.String,JavaSrcTreeFile> XXXjavaFiles
All file.java containing in this package.


javaPublicClasses

private final java.util.List<JavaSources.ClassDataOrJavaSrcFile> javaPublicClasses
Same content as #javaFiles, but the key is the class name.


pkgHasFiles

private boolean pkgHasFiles
Set to true if #setFileJava(String, File, String, String, String, boolean) is called the first time.


replaceCinfo

private ConfigSrcPathPkg_ifc.Set replaceCinfo
If this info is found, a stc-file is determined for the package to replace structure info instead given Java-files.


pkgIdents

private final LocalIdents pkgIdents
Index of all sub-packages and classes available in the package, package privates too. Only the field LocalIdents.typeIdents is used, because a package has no fields. But the type LocalIndents is necessary to implement the method JavaSources.ClassDataOrJavaSrcFile.getLocalIdents(String) to support getting data to an identifier inside the package (may be sub-package or a file or a class known in package).

Constructor Detail

JavaSrcTreePkg

public JavaSrcTreePkg(JavaSrcTreePkg parent,
                      java.lang.String pkgPath,
                      java.lang.String pkgName,
                      ConfigSrcPathPkg_ifc.Set replaceCinfo)
Parameters:
pkgIdent -
javaSrcPath -
Method Detail

getOrAddPkg

public JavaSrcTreePkg getOrAddPkg(java.lang.String pkgPath,
                                  java.lang.String pkgName,
                                  ConfigSrcPathPkg_ifc.Set replaceCinfo)
returns the Instance, which represents the given package name. If the Instance doesn't exist, it is created. If it exists already before this call, and its replaceCinfo is null, then the given parameter replaceCinfo is used to set it. If the replaceCinfo was given before, and the parameter replaceCinfo is given here too, it is tested whether it contains the same. Elsewhere a IllegalArgumentException is thrown.

Parameters:
pkgPath - The full path from root
pkgName - The name of the new package
replaceCinfo - if not null, then it is the info to build the C-files /search the stc-file for all non-existing, but needed Java-files of the package.
Returns:
The package management instance.

putClassType

public void putClassType(ClassData data)
Adds the given type info to the pkgIdents.

Parameters:
data - The type info.

getPkgPath

public java.lang.String getPkgPath()

XXXgetJavaFiles

public final java.util.TreeMap<java.lang.String,JavaSrcTreeFile> XXXgetJavaFiles()

getPublicClasses

public final java.util.List<JavaSources.ClassDataOrJavaSrcFile> getPublicClasses()

xxxaddStdTypes

public void xxxaddStdTypes(LocalIdents types)
Adds all standard types to the package. This method will be called if any file is containing in the package. It means, the package is the immediate package of any class. This method will be called too while creating a standard package (java.lang).

Parameters:
types -

setFileJava

public JavaSources.ClassDataOrJavaSrcFile setFileJava(java.lang.String javaSrcPath,
                                                      java.io.File fileJava,
                                                      java.lang.String sFileNameJava,
                                                      ConfigSrcPathPkg_ifc.Set info,
                                                      java.lang.String prefixCFile,
                                                      java.lang.String suffixCFile,
                                                      java.lang.String prefixNames,
                                                      java.lang.String suffixNames,
                                                      java.lang.String stcPath,
                                                      boolean translateToC)
Registers the first occurrence of a found Java file or set the ConfigSrcPathPkg_ifc.Set for an existing file without replaceCinfo

Parameters:
itsPkg - The package where the file is member of.
javaSrcPath - The source path where the file is found first time.
fileJava - The File instance ready to open source file.
sFileNameJava - The file name without path but with extension .java without directories.
prefixCFile - The prefix to build the C class name and the C file name. The part after the last slash / is the prefix for class names. The prefix should ended with slash if the file name has no prefix, but a path to store the to create *.c and *.h files are given. The prefix may contain "".
suffixCFile - The suffix to build the C class name and the C file name.
stcPath - null or a special path where the stc-file is located.
translateToC - false than the file should not be translate to C, instead the stc-file should be used any time. This is if it is a standard class or a users class, which is located in a library.
Returns:

reportClasses

public void reportClasses(Report report)

getChild

public JavaSrcTreePkg getChild(java.lang.String key)
Description copied from interface: SortedTree
Searches the first child with given key from the given node this.

Specified by:
getChild in interface SortedTree<JavaSrcTreePkg>
Parameters:
key - The key of the demanded child. The implementation may have extra possibilities in addressing children with strings. The sKey can be representing more as a simple string as a attribute in children. It may be comparable with the ability of XPATH in XML. But it will be a feature of Implementation and is not defined as a basic feature of this interface.
sKey==null or sKey="" should be accepted. Than the first child independed on its key is returned. This is useable if only one child exists, but with unknown key.
Returns:
The first child with the given key or null if there is no such child.

getPkgLevelIdents

public LocalIdents getPkgLevelIdents()
gets the pkg-level-idents. It contains all types which are known at this package level (all files of package.).


iterChildren

public java.util.Iterator<JavaSrcTreePkg> iterChildren()
Description copied from interface: SortedTree
Returns an iterator through the list of all children of the node.

Specified by:
iterChildren in interface SortedTree<JavaSrcTreePkg>
Returns:
The iterator or null if there isn't any children.

iterChildren

public java.util.Iterator<JavaSrcTreePkg> iterChildren(java.lang.String key)
Description copied from interface: SortedTree
Returns an iterator through the list of all children with the given key.

Specified by:
iterChildren in interface SortedTree<JavaSrcTreePkg>
Parameters:
key - The key of the demanded child. The implementation may have extra possibilities, see getChild(String).
Returns:
A iterator through the list of all children with the given key or null if there is no such child.

listChildren

public java.util.List<JavaSrcTreePkg> listChildren()
Description copied from interface: SortedTree
Returns a List of all children of the node.

Specified by:
listChildren in interface SortedTree<JavaSrcTreePkg>
Returns:
The List or null if there isn't any children.

listChildren

public java.util.List<JavaSrcTreePkg> listChildren(java.lang.String key)
Description copied from interface: SortedTree
Returns a List of all children with the given key.

Specified by:
listChildren in interface SortedTree<JavaSrcTreePkg>
Parameters:
key - The key of the demanded child. The implementation may have extra possibilities, see getChild(String).
Returns:
A List of all children with the given key or null if there is no such child.

getClassData

public ClassData getClassData()
Description copied from interface: JavaSources.ClassDataOrJavaSrcFile
Returns the ClassData of the instance, or null. If the instance is of type ClassData, it returns the instance itself. If the instance is of type JavaSrcTreeFile, it returns the associated ClassData, if the file is translated yet or the stc-file is read already. If the file isn't translated, it returns null.

Specified by:
getClassData in interface JavaSources.ClassDataOrJavaSrcFile

getJavaSrc

public JavaSrcTreeFile getJavaSrc()
Implements JavaSources.ClassDataOrJavaSrcFile.getJavaSrc()

Specified by:
getJavaSrc in interface JavaSources.ClassDataOrJavaSrcFile

getJavaPkg

public JavaSrcTreePkg getJavaPkg()
Implements JavaSources.ClassDataOrJavaSrcFile.getJavaPkg()

Specified by:
getJavaPkg in interface JavaSources.ClassDataOrJavaSrcFile

getLocalIdents

public LocalIdents getLocalIdents(java.lang.String sPkgName)
Returns the identifier of classes or packages, which are available in this package. It may be sub-package or a file or a class known in package. implements JavaSources.ClassDataOrJavaSrcFile.getLocalIdents(java.lang.String)

Specified by:
getLocalIdents in interface JavaSources.ClassDataOrJavaSrcFile
Parameters:
sPkgName: - It is ignored.
Returns:
Especially list of all types in the element. If it is a package, the types may be the files in the package or sub-packages.

getTypeName

public java.lang.String getTypeName()
Implements JavaSources.ClassDataOrJavaSrcFile.getTypeName()

Specified by:
getTypeName in interface JavaSources.ClassDataOrJavaSrcFile

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getReplaceCinfo

public ConfigSrcPathPkg_ifc.Set getReplaceCinfo()
Description copied from interface: JavaSources.ClassDataOrJavaSrcFile
Returns the informations to find out where the C-file is found and which pre/suffix are valid.

Specified by:
getReplaceCinfo in interface JavaSources.ClassDataOrJavaSrcFile
Returns:
null if there are not such informations. That is especially for super-paths.

isToTranslate

public boolean isToTranslate()
returns false because a package isn't to translate.

Specified by:
isToTranslate in interface JavaSources.ClassDataOrJavaSrcFile
Returns:
false if always the stc-File is to be read, or it is a ClassData.
See Also:
JavaSources.ClassDataOrJavaSrcFile.isToTranslate()

setClassData

public void setClassData(ClassData data)
Specified by:
setClassData in interface JavaSources.ClassDataOrJavaSrcFile