Source Code Cross Referenced for FileStructureContainer.java in  » IDE » Schmortopf » Schmortopf » FileStructure » DataStorage » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE » Schmortopf » Schmortopf.FileStructure.DataStorage 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package Schmortopf.FileStructure.DataStorage;
002:
003:        /**
004:         *  Used in FileStructuresDataFile for holding
005:         *  one single Vector with FileStructureDescriptions
006:         *  and providing methods for loading and saving
007:         *  from/to a file.
008:         */
009:
010:        import java.util.*;
011:        import java.io.*;
012:
013:        import Schmortopf.Utility.Vectorizable;
014:        import Schmortopf.FileStructure.Descriptions.*;
015:
016:        public class FileStructureContainer implements  Vectorizable {
017:
018:            private String jarFilePath = "";
019:            private String jarFileVersionIdentifier = "";
020:
021:            private Vector fileStructureDescriptions = new Vector();
022:
023:            /**
024:             *  Usual constructor :
025:             *  Creates the object and gets the versionidentifier from
026:             *  the jarfile with the passed filepath.
027:             */
028:            public FileStructureContainer(final String jarFilePath) {
029:                this .jarFilePath = jarFilePath;
030:                this .jarFileVersionIdentifier = FileStructuresDataFile
031:                        .CalculateVersionIdentifierFor(this .jarFilePath);
032:            } // Constructor
033:
034:            /**
035:             *  constructor 2:
036:             *  Creates the object and takes the passed versionIdentifier.
037:             *  This is used f.ex. for the projectfiles, where there actually
038:             *  is not one single jarfile, but many java textfiles.
039:             *  jarFilePath has no meaning in this case.
040:             */
041:            public FileStructureContainer(final String jarFilePath,
042:                    final String versionIdentifier) {
043:                this .jarFilePath = jarFilePath;
044:                this .jarFileVersionIdentifier = versionIdentifier;
045:            } // Constructor
046:
047:            /**
048:             *  Constructor for use, when the object will be recreated
049:             *  using createFromVectorRepresentation().
050:             */
051:            public FileStructureContainer() {
052:            }
053:
054:            /**
055:             *  Removes all FileStructureDescriptions,
056:             *  but doesn't release any other instances.
057:             */
058:            public void removeAllDescriptions() {
059:                this .fileStructureDescriptions.setSize(0);
060:            }
061:
062:            public void addFileStructureDescription(
063:                    final FileStructureDescription fsd) {
064:                this .fileStructureDescriptions.addElement(fsd);
065:            }
066:
067:            /**
068:             *  Returns the filename of the file, from which the
069:             *  hashtable data was created.
070:             */
071:            public String getFilePath() {
072:                return this .jarFilePath;
073:            }
074:
075:            /**
076:             *  Returns the fileIdentifier of the file, from which the
077:             *  hashtable data was created, at the time when this was done.
078:             */
079:            public String getFileIdentifier() {
080:                return this .jarFileVersionIdentifier;
081:            }
082:
083:            public FileStructureDescription[] getFileStructureDescriptions() {
084:                final FileStructureDescription[] descriptions = new FileStructureDescription[this .fileStructureDescriptions
085:                        .size()];
086:                this .fileStructureDescriptions.copyInto(descriptions);
087:                return descriptions;
088:            }
089:
090:            public int getNumberOfFileStructureDescriptions() {
091:                return this .fileStructureDescriptions.size();
092:            }
093:
094:            /**
095:             *  Gets the fsd at the passed index. No checks are made.
096:             */
097:            public FileStructureDescription getFSDAt(int index) {
098:                return (FileStructureDescription) this .fileStructureDescriptions
099:                        .elementAt(index);
100:            }
101:
102:            /**
103:             *  returns the VectorRepresentation of the object's datacontent
104:             */
105:            public Vector getVectorRepresentation() throws Exception {
106:                final Vector rep = new Vector();
107:                rep.addElement(this .jarFilePath);
108:                rep.addElement(this .jarFileVersionIdentifier);
109:                // add the number of fsd's to follow :
110:                rep.addElement(new Integer(this .fileStructureDescriptions
111:                        .size()));
112:                // and add all fsd reps :
113:                FileStructureDescription fsd = null;
114:                for (int i = 0; i < this .fileStructureDescriptions.size(); i++) {
115:                    fsd = (FileStructureDescription) this .fileStructureDescriptions
116:                            .elementAt(i);
117:                    rep.addElement(fsd.getVectorRepresentation());
118:                }
119:                fsd = null;
120:                return rep;
121:            } // getVectorRepresentation
122:
123:            /**
124:             *   Sets the object's content to the passed vectorRepresentation.
125:             */
126:            public void createFromVectorRepresentation(Vector rep) {
127:                this .jarFilePath = (String) rep.elementAt(0);
128:                this .jarFileVersionIdentifier = (String) rep.elementAt(1);
129:                final int numberOfFSDReps = ((Integer) rep.elementAt(2))
130:                        .intValue();
131:                Vector fsdRep;
132:                FileStructureDescription fsd;
133:                for (int i = 0; i < numberOfFSDReps; i++) {
134:                    fsdRep = (Vector) rep.elementAt(i + 3);
135:                    fsd = new FileStructureDescription();
136:                    fsd.createFromVectorRepresentation(fsdRep);
137:                    fsdRep.removeAllElements();
138:                    this .fileStructureDescriptions.addElement(fsd);
139:                }
140:                fsdRep = null;
141:                fsd = null;
142:                this .freeVector(rep);
143:            } // createFromVectorRepresentation
144:
145:            /**
146:             *  Recursive method, which removes any vector's in the passed vector.
147:             */
148:            private void freeVector(Vector v) {
149:                Vector vHelp = null;
150:                if (v != null) {
151:                    for (int i = 0; i < v.size(); i++) {
152:                        if (v.elementAt(i) instanceof  Vector) {
153:                            vHelp = (Vector) v.elementAt(i);
154:                            this .freeVector(vHelp);
155:                        }
156:                    }
157:                    v.removeAllElements();
158:                }
159:                vHelp = null;
160:            }
161:
162:            /**
163:             *  This can be called before a container isnt used anymore.
164:             *  It helps the GC to remove not used memory.
165:             */
166:            public void removeAll() {
167:                // Try to remove as much references *between* objects as possible,
168:                // before they are left to the GC, and set the to null :
169:                if (this .fileStructureDescriptions != null) {
170:                    this .fileStructureDescriptions.removeAllElements();
171:                }
172:                this .fileStructureDescriptions = null;
173:                this .jarFilePath = null;
174:                this .jarFileVersionIdentifier = null;
175:            }
176:
177:        } // FileStructureContainer
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.