I cannot create sort method to put folders and files into tree structure. I am using composite pattern, I have Leaf (File) and Node(Directory). And also I have a list of Entries. I cannot figure out how to elagantly to sort them and create tree structure.
Here is an example of output
org/apache/logging/log4j/core/osgi/is directory !
org/apache/logging/log4j/core/pattern/is directory !
org/apache/logging/log4j/core/selector/is directory !
org/apache/logging/log4j/core/tools/is directory !
org/apache/logging/log4j/core/util/is directory !
Log4j-config.xsd
Log4j-events.dtd
Log4j-events.xsd
Log4j-levels.xsd
META-INF/LICENSE
META-INF/log4j-provider.properties
META-INF/NOTICE
META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat
META-INF/services/javax.annotation.processing.Processor
org/apache/logging/log4j/core/AbstractLifeCycle.class
org/apache/logging/log4j/core/AbstractLogEvent.class
org/apache/logging/log4j/core/appender/AbstractAppender.class
I can determine in what directory put entry only by path. I have no idea how to do this correctly.
I have two classes (composite pattern) EntryFile and EntryFolder they both extends Entry, EntryFolder in turn has method to add Entry objects.
Please suggest how to do this. My brain doesn't want to work.
Thx in advance.
Aucun commentaire:
Enregistrer un commentaire