summaryrefslogtreecommitdiff
path: root/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData
diff options
context:
space:
mode:
Diffstat (limited to 'javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData')
-rwxr-xr-xjavainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/DisplayPackageDescription.java52
-rwxr-xr-xjavainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/PackageDescription.java120
-rwxr-xr-xjavainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/ProductDescription.java54
-rwxr-xr-xjavainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/SetupDataProvider.java4
-rwxr-xr-xjavainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/XMLPackageDescription.java74
5 files changed, 152 insertions, 152 deletions
diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/DisplayPackageDescription.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/DisplayPackageDescription.java
index f7926c4fd314..76ddef130e8b 100755
--- a/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/DisplayPackageDescription.java
+++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/DisplayPackageDescription.java
@@ -1,7 +1,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -37,7 +37,7 @@ public class DisplayPackageDescription {
private PackageDescription data;
private int size = 0;
-
+
public DisplayPackageDescription(PackageDescription data) {
this.data = data;
// Setting default module settings for modules, that are not hidden
@@ -49,21 +49,21 @@ public class DisplayPackageDescription {
public String getDescription() {
return data.getDescription();
}
-
+
public int getSize() {
return size; // using local size
}
-
+
public int getState() {
return data.getSelectionState();
}
-
+
private int getSize(TreeNode peerNode) {
// return peerNode.isLeaf() ? data.getAccumulatedSize() : data.getSize();
// using size from PackageDescription, which is pkgSize (and that is defined in xpd file)
return data.getSize();
}
-
+
public void setState(TreeNode node, int newState) {
if ((data.getSelectionState() != PackageDescription.IGNORE) && data.isOptional()) {
data.setSelectionState(newState);
@@ -72,12 +72,12 @@ public class DisplayPackageDescription {
if (!node.isLeaf()) {
size = data.getSize(); // -> that is the value defined in xpd file
- for (Enumeration e = node.children(); e.hasMoreElements();) {
+ for (Enumeration e = node.children(); e.hasMoreElements();) {
TreeNode child = (TreeNode)e.nextElement();
DisplayPackageDescription childInfo = getInfo(child);
-
+
childInfo.setState(child, newState);
-
+
if (childInfo.isSelected()) {
size += childInfo.getSize(child);
}
@@ -90,9 +90,9 @@ public class DisplayPackageDescription {
public void toggleState(TreeNode node) {
int state = data.getSelectionState();
-
+
if (state != PackageDescription.IGNORE) {
-
+
if (state == PackageDescription.REMOVE) {
setState(node, PackageDescription.DONT_REMOVE);
} else if ((state == PackageDescription.DONT_REMOVE) || (state == PackageDescription.REMOVE_SOME)) {
@@ -102,7 +102,7 @@ public class DisplayPackageDescription {
} else {
setState(node, PackageDescription.DONT_INSTALL);
}
-
+
if (!node.isLeaf()) {
updateState(node);
}
@@ -110,16 +110,16 @@ public class DisplayPackageDescription {
try {
TreeNode parent = node.getParent();
DisplayPackageDescription parentInfo = getInfo(parent);
-
+
parentInfo.updateState(parent);
try {
TreeNode grandpa = parent.getParent();
DisplayPackageDescription grandpaInfo = getInfo(grandpa);
-
+
grandpaInfo.updateState(grandpa);
} catch (java.lang.IllegalArgumentException e) {
/* ignore */
- }
+ }
} catch (java.lang.IllegalArgumentException e) {
/* ignore */
@@ -133,10 +133,10 @@ public class DisplayPackageDescription {
InstallData installdata = InstallData.getInstance();
size = data.getSize(); // -> that is the value defined in xpd file
- for (Enumeration e = node.children(); e.hasMoreElements();) {
+ for (Enumeration e = node.children(); e.hasMoreElements();) {
TreeNode child = (TreeNode) e.nextElement();
DisplayPackageDescription childInfo = getInfo(child);
-
+
int childState = childInfo.getState();
if ((state == PackageDescription.DONT_KNOW) || (state == PackageDescription.IGNORE)) {
@@ -152,7 +152,7 @@ public class DisplayPackageDescription {
size += childInfo.getSize(child);
}
}
-
+
data.setSelectionState(state);
}
@@ -160,8 +160,8 @@ public class DisplayPackageDescription {
public void updateSize(TreeNode node)
{
size = data.getSize(); // -> that is the value defined in xpd file
-
- for (Enumeration e = node.children(); e.hasMoreElements();) {
+
+ for (Enumeration e = node.children(); e.hasMoreElements();) {
TreeNode child = (TreeNode) e.nextElement();
DisplayPackageDescription childInfo = getInfo(child);
if (childInfo.isSelected()) {
@@ -173,23 +173,23 @@ public class DisplayPackageDescription {
public String toString() {
return data.getName();
}
-
+
static public boolean is(Object o) {
- return (o != null)
+ return (o != null)
&& (o.getClass().getName().equals("org.openoffice.setup.SetupData.DisplayPackageDescription"));
}
-
+
public boolean isSelected() {
int state = data.getSelectionState();
- return (state == PackageDescription.INSTALL) || (state == PackageDescription.INSTALL_SOME)
+ return (state == PackageDescription.INSTALL) || (state == PackageDescription.INSTALL_SOME)
|| (state == PackageDescription.REMOVE) || (state == PackageDescription.REMOVE_SOME);
}
-
+
private DisplayPackageDescription getInfo(TreeNode node) throws java.lang.IllegalArgumentException {
if (node == null) {
throw new java.lang.IllegalArgumentException();
}
-
+
DisplayPackageDescription info = (DisplayPackageDescription)((DefaultMutableTreeNode)node).getUserObject();
if ((info != null) && is(info)) {
return info;
diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/PackageDescription.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/PackageDescription.java
index 4ed331bff2d7..aa6969750186 100755
--- a/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/PackageDescription.java
+++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/PackageDescription.java
@@ -1,7 +1,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -24,7 +24,7 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-
+
package org.openoffice.setup.SetupData;
import org.openoffice.setup.Util.Parser;
@@ -42,7 +42,7 @@ import javax.swing.tree.TreeNode;
* @author Ingo Schmidt
*/
public class PackageDescription implements TreeNode {
-
+
public final static int NOTA_UNIT= 0;
public final static int RPM_UNIT = 1;
public final static int PKG_UNIT = 2;
@@ -50,7 +50,7 @@ public class PackageDescription implements TreeNode {
* public final static int TAR_UNIT = 4;
* public final static int TGZ_UNIT = 5;
*/
-
+
public final static int DONT_INSTALL = 0;
public final static int INSTALL = 1;
public final static int INSTALL_SOME = 2;
@@ -59,14 +59,14 @@ public class PackageDescription implements TreeNode {
public final static int REMOVE_SOME = 5;
public final static int IGNORE = 6;
public final static int DONT_KNOW = 7;
-
+
/* hierarchy information */
private Vector children = null;
private PackageDescription parent = null;
-
+
/* did the user select this package */
private int usrSelectionState = DONT_KNOW;
-
+
/* display information */
private String dpyName = "";
private String dpyDescription = "";
@@ -80,7 +80,7 @@ public class PackageDescription implements TreeNode {
private boolean isOptional = true;
private boolean dontUninstall = false;
private boolean allChildrenHidden = false;
-
+
/* package information */
private String pkgMD5Sum = "";
private String pkgFileName = "";
@@ -106,41 +106,41 @@ public class PackageDescription implements TreeNode {
private boolean isNewInstalled = false;
private boolean wasAlreadyInstalled = false;
private boolean ignoreDependsForUninstall = false;
-
+
/* Saving the default selection state. This is necessary, if the user chooses
- * the custom installation type, makes changes, and then changes into
+ * the custom installation type, makes changes, and then changes into
* the typical installation set. Then all user settings have to be removed again.
* On the other hand, if the user then changes to the custom installation type
* again, he probably wants to see the settings he has done before.
*/
-
+
private int typicalSelectionState = DONT_KNOW; // Saving settings for typical installation
private int customSelectionState = DONT_KNOW; // Saving settings for custom installation
private int startSelectionState = DONT_KNOW; // Saving settings at start of installation
public PackageDescription() {}
-
- /**
- * construct only with package information to wrap
+
+ /**
+ * construct only with package information to wrap
*/
protected PackageDescription(XMLPackageDescription p) {
this(p, (PackageDescription)null);
}
-
+
private PackageDescription(XMLPackageDescription descriptionData, PackageDescription parent) {
-
+
this.parent = parent;
children = new Vector();
parse(descriptionData);
-
+
/* sort according to display sort key */
Collections.sort(children, new PackageComparator());
}
-
+
/**
* retrieve information about the package properties
*/
-
+
public String getName() {
return dpyName;
}
@@ -148,7 +148,7 @@ public class PackageDescription implements TreeNode {
public void setName(String name) {
dpyName = name;
}
-
+
public String getDescription() {
return dpyDescription;
}
@@ -156,11 +156,11 @@ public class PackageDescription implements TreeNode {
public String getCheckSolaris() {
return checkSolaris;
}
-
+
public int getSize() {
return pkgSize;
}
-
+
public void setSize(int size) {
pkgSize = size;
}
@@ -180,7 +180,7 @@ public class PackageDescription implements TreeNode {
// // Should only be accumulated for selected modules
// PackageDescription data = (PackageDescription) e.nextElement();
// size += data.getSize();
- // }
+ // }
//
// return size;
// }
@@ -188,7 +188,7 @@ public class PackageDescription implements TreeNode {
public boolean isOptional() {
return isOptional;
}
-
+
public boolean isHidden() {
return isHidden;
}
@@ -268,7 +268,7 @@ public class PackageDescription implements TreeNode {
public boolean isDefault() {
return isDefault;
}
-
+
public String getMD5() {
return pkgMD5Sum;
}
@@ -280,7 +280,7 @@ public class PackageDescription implements TreeNode {
public void setIsRelocatable(boolean relocatable) {
isRelocatable = relocatable;
}
-
+
public String getPackageName() {
return pkgFileName;
}
@@ -301,7 +301,7 @@ public class PackageDescription implements TreeNode {
public int getSelectionState() {
return usrSelectionState;
}
-
+
public void setSelectionState(int state) {
usrSelectionState = state;
}
@@ -309,15 +309,15 @@ public class PackageDescription implements TreeNode {
public int getCustomSelectionState() {
return customSelectionState;
}
-
+
public void setCustomSelectionState(int state) {
customSelectionState = state;
}
-
+
public int getTypicalSelectionState() {
return typicalSelectionState;
}
-
+
public void setTypicalSelectionState(int state) {
typicalSelectionState = state;
}
@@ -325,11 +325,11 @@ public class PackageDescription implements TreeNode {
public int getStartSelectionState() {
return startSelectionState;
}
-
+
public void setStartSelectionState(int state) {
startSelectionState = state;
}
-
+
public boolean isAllChildrenHidden() {
return allChildrenHidden;
}
@@ -341,11 +341,11 @@ public class PackageDescription implements TreeNode {
public void setIsHidden(boolean hidden) {
isHidden = hidden;
}
-
+
public boolean pkgExists() {
return pkgExists;
}
-
+
public void setPkgExists(boolean exists) {
pkgExists = exists;
}
@@ -395,11 +395,11 @@ public class PackageDescription implements TreeNode {
*/
private String getLocalizedValue(XMLPackageDescription packageData, String section, Locale l) {
String localizedValue = "";
-
+
String countryString = l.getCountry();
String languageString = l.getLanguage();
String localeString = languageString + "_" + countryString;
-
+
XMLPackageDescription subPackage = packageData.getElement(section, "lang", localeString);
if (subPackage == null) {
subPackage = packageData.getElement(section, "lang", languageString);
@@ -408,21 +408,21 @@ public class PackageDescription implements TreeNode {
}
}
if (subPackage != null) {
- localizedValue = subPackage.getValue();
+ localizedValue = subPackage.getValue();
}
-
+
return localizedValue;
}
-
+
/**
* parse the wrapped package description
*/
-
+
private void parse(XMLPackageDescription data) {
-
+
XMLPackageDescription section;
XMLPackageDescription subSection;
-
+
/* information about how to display the node */
section = data.getElement("display");
if (section != null) {
@@ -436,7 +436,7 @@ public class PackageDescription implements TreeNode {
Locale locale = Locale.getDefault();
dpyName = getLocalizedValue(section, "name", locale);
dpyDescription = getLocalizedValue(section, "description", locale);
-
+
subSection = section.getElement("sortkey");
if (subSection != null) {
String sort = subSection.getValue();
@@ -520,7 +520,7 @@ public class PackageDescription implements TreeNode {
}
}
-
+
/* query information about the physical (rpm/pkg/msi...) package itself */
section = data.getElement("installunit");
if (section != null) {
@@ -532,7 +532,7 @@ public class PackageDescription implements TreeNode {
pkgType = PKG_UNIT;
}
}
-
+
subSection = section.getElement("size");
if (subSection != null) {
String sz = subSection.getValue();
@@ -548,7 +548,7 @@ public class PackageDescription implements TreeNode {
}
subSection = section.getElement("md5");
if (subSection != null) {
- pkgMD5Sum = subSection.getValue();
+ pkgMD5Sum = subSection.getValue();
}
subSection = section.getElement("name");
if (subSection != null) {
@@ -578,7 +578,7 @@ public class PackageDescription implements TreeNode {
}
}
-
+
/* line up the subpackages */
for (Enumeration enumPackages = data.elements(); enumPackages.hasMoreElements(); ) {
XMLPackageDescription p = (XMLPackageDescription) enumPackages.nextElement();
@@ -586,44 +586,44 @@ public class PackageDescription implements TreeNode {
children.add(new PackageDescription(p, this));
}
}
- }
-
+ }
+
/**
* sort according to the display sortkey
*/
-
+
private class PackageComparator implements Comparator {
public int compare(Object w1, Object w2) {
return ((PackageDescription) w1).dpySortKey - ((PackageDescription) w2).dpySortKey;
}
}
-
+
/**
* implement a TreeNode interface for convenient travelling through the data
*/
-
+
private class PackageEnumeration implements Enumeration {
-
+
Enumeration e;
protected PackageEnumeration() {
e = children.elements();
- }
+ }
public boolean hasMoreElements() {
return e.hasMoreElements();
}
public Object nextElement() {
return e.nextElement();
- }
+ }
}
/**
- * TreeNode interface
+ * TreeNode interface
*/
public Enumeration children() {
return new PackageEnumeration();
}
-
+
public boolean getAllowsChildren() {
return true;
}
@@ -639,11 +639,11 @@ public class PackageDescription implements TreeNode {
public int getChildCount() {
return children.size();
}
-
+
public int getIndex(TreeNode node) {
return children.indexOf(node);
}
-
+
// public PackageDescription getParent() {
// return parent;
// }
@@ -655,5 +655,5 @@ public class PackageDescription implements TreeNode {
public boolean isLeaf() {
return children.size() == 0;
}
-
+
}
diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/ProductDescription.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/ProductDescription.java
index e5933a996834..f2bdc6161964 100755
--- a/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/ProductDescription.java
+++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/ProductDescription.java
@@ -1,7 +1,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -40,31 +40,31 @@ import java.util.regex.Pattern;
* @author Christof Pintaske
*/
public class ProductDescription {
-
+
private class Pair {
public Pattern search;
public String replacement;
-
+
public Pair(Pattern key, String value) {
search = key;
replacement = value;
}
}
-
+
private Vector macro; /* macro list with precompiled regex patterns */
private HashMap map; /* conventional key-value pairs */
private String backslashText = "THIS_IS_A_BACKSLASH";
-
- /**
+
+ /**
* read properties from package description data
*/
-
+
protected ProductDescription(XMLPackageDescription descriptionData) {
macro = new Vector();
map = new HashMap();
parse(descriptionData);
}
-
+
/**
* retrieve information about general installation properties
*/
@@ -104,21 +104,21 @@ public class ProductDescription {
System.out.println("Key: " + pair.search.pattern() + " Value: " + pair.replacement );
}
}
-
+
public String get(String key) {
return (String) map.get(key);
}
private boolean doMaskBackslash(String[] arr) {
boolean changed = false;
-
+
int index = arr[0].indexOf('\\');
if ( index >= 0 ) {
arr[0] = arr[0].replaceAll("\\", backslashText);
// arr[0] = arr[0].replace("\\", backslashText);
changed = true;
}
-
+
return changed;
}
@@ -129,9 +129,9 @@ public class ProductDescription {
}
public String replaceMacros(String s) {
-
+
String result = s;
-
+
for (int i = 0; i < macro.size(); i++) {
Pair pair = (Pair) macro.get(i);
Pattern pattern = pair.search;
@@ -152,13 +152,13 @@ public class ProductDescription {
return result;
}
-
+
/**
* parse the wrapped package description
*/
-
+
private void parse(XMLPackageDescription data) {
-
+
XMLPackageDescription section;
/* product description is a leaf at the root */
@@ -167,7 +167,7 @@ public class ProductDescription {
if (section != null) {
parse(section);
}
- } else {
+ } else {
InstallData installData = InstallData.getInstance();
/* check for a default installation directory */
@@ -176,8 +176,8 @@ public class ProductDescription {
String value = section.getValue();
if (value != null) {
installData.setDefaultDir(value);
- // installData.setInstallDir(value);
- }
+ // installData.setInstallDir(value);
+ }
}
/* check for a default product directory */
@@ -186,7 +186,7 @@ public class ProductDescription {
String value = section.getValue();
if (value != null) {
installData.setProductDir(value);
- }
+ }
}
/* check for the package format of this installation set */
@@ -195,7 +195,7 @@ public class ProductDescription {
String value = section.getValue();
if (value != null) {
installData.setPackageFormat(value);
- }
+ }
}
/* check for the package directory of this installation set */
@@ -204,7 +204,7 @@ public class ProductDescription {
String value = section.getValue();
if ((value != null) && (! value.equals(""))) {
installData.setPackageSubdir(value);
- }
+ }
}
/* check for the architecture of this installation set */
@@ -213,7 +213,7 @@ public class ProductDescription {
String value = section.getValue();
if ((value != null) && (! value.equals(""))) {
installData.setArchitecture(value);
- }
+ }
}
section = data.getElement("multilingual");
@@ -222,7 +222,7 @@ public class ProductDescription {
if ((value != null) && (! value.equals(""))) {
boolean multilingualValue = Parser.parseBoolean(value);
installData.setIsMultiLingual(multilingualValue);
- }
+ }
}
/* check for the update behaviour of this installation set */
@@ -243,7 +243,7 @@ public class ProductDescription {
if (value != null) {
int intValue = Integer.parseInt(value);
installData.setProductMinor(intValue);
- }
+ }
}
section = data.getElement("hideeula");
@@ -252,7 +252,7 @@ public class ProductDescription {
if ((value != null) && (! value.equals(""))) {
boolean hideeulaValue = Parser.parseBoolean(value);
installData.setHideEula(hideeulaValue);
- }
+ }
}
/* check for any macro definitions */
@@ -261,7 +261,7 @@ public class ProductDescription {
if (p.getKey().equals("macro")) {
String key = p.getAttribute("key");
String value = p.getValue();
-
+
if ((key != null) && (value != null)) {
String match = "\\$\\{" + key + "\\}";
Pattern pattern = Pattern.compile(match, Pattern.CASE_INSENSITIVE);
diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/SetupDataProvider.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/SetupDataProvider.java
index 55b6b06a86e0..f83657cd6b64 100755
--- a/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/SetupDataProvider.java
+++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/SetupDataProvider.java
@@ -1,7 +1,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -74,7 +74,7 @@ public class SetupDataProvider {
DefaultMutableTreeNode node = new DefaultMutableTreeNode();
node.setUserObject(new DisplayPackageDescription(data));
-
+
for (Enumeration e = data.children(); e.hasMoreElements(); ) {
PackageDescription child = (PackageDescription) e.nextElement();
diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/XMLPackageDescription.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/XMLPackageDescription.java
index ab7aef57b526..c660e43d3454 100755
--- a/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/XMLPackageDescription.java
+++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/SetupData/XMLPackageDescription.java
@@ -1,7 +1,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -48,25 +48,25 @@ public class XMLPackageDescription {
* fill the package description tree by handling the SAXParser events
*/
private class PackageDescriptionHandler extends DefaultHandler {
-
+
private XMLPackageDescription root;
private Stack stack;
-
+
public PackageDescriptionHandler(XMLPackageDescription base) {
root = base;
stack = new Stack();
}
-
+
private PackageDescriptionHandler() {
/* forbidden */
}
-
+
public XMLPackageDescription getDescription() {
return root;
}
-
+
/* implement the DefaultHandler interface */
-
+
public void characters(char[] ch, int start, int length) {
XMLPackageDescription entity = (XMLPackageDescription) stack.peek();
entity.value = entity.value == null ? new String(ch, start, length)
@@ -81,12 +81,12 @@ public class XMLPackageDescription {
public void startElement(String uri, String localName, String qName, Attributes attributes) {
XMLPackageDescription parent = (XMLPackageDescription) stack.peek();
XMLPackageDescription entity = new XMLPackageDescription();
-
+
entity.key = qName;
for (int i = 0; i < attributes.getLength(); i++) {
entity.attributes.put(attributes.getQName(i), attributes.getValue(i));
}
-
+
parent.add(entity);
stack.push(entity);
}
@@ -106,11 +106,11 @@ public class XMLPackageDescription {
System.err.println("Warning:" + e);
}
}
-
+
/**
* general storage for XML elements
*/
-
+
private String key; /* XML element name */
private String value; /* XML element characters */
private Hashtable attributes; /* XML element attributes */
@@ -122,11 +122,11 @@ public class XMLPackageDescription {
attributes = new Hashtable();
children = new Vector();
}
-
+
private void add(XMLPackageDescription p) {
children.add(p);
}
-
+
/**
* helper routines to find content information
*/
@@ -134,12 +134,12 @@ public class XMLPackageDescription {
return key;
}
protected String getAttribute(String key) {
- return (String) attributes.get(key);
+ return (String) attributes.get(key);
}
protected String getValue() {
return value;
}
- protected XMLPackageDescription getElement(String key) {
+ protected XMLPackageDescription getElement(String key) {
return getElement(key, null, null);
}
protected XMLPackageDescription getElement(String key, String attrKey, String attrValue) {
@@ -165,7 +165,7 @@ public class XMLPackageDescription {
if ((self != null) && self.equals(name))
return this;
-
+
XMLPackageDescription found = null;
for (Enumeration e = children.elements(); e.hasMoreElements();) {
XMLPackageDescription child = (XMLPackageDescription) e.nextElement();
@@ -175,24 +175,24 @@ public class XMLPackageDescription {
break;
}
}
- }
+ }
return found;
}
-
- /**
+
+ /**
* adjust the tree so that all children have a matching parent and not just
* the ones they got by reading files in random order
*/
- private void adjust(XMLPackageDescription root) {
+ private void adjust(XMLPackageDescription root) {
String self = (String) attributes.get("name");
-
+
for (int i = children.size() - 1; i >= 0; --i) {
XMLPackageDescription child = (XMLPackageDescription) children.elementAt(i);
String childParentName = child.getAttribute("parent");
if (childParentName != null) {
-
+
child.adjust(root);
-
+
if ((childParentName != null) && (childParentName.length() > 0) && (! childParentName.equals(self))) {
XMLPackageDescription newParent = root.findPackage(childParentName);
if (newParent != null) {
@@ -203,10 +203,10 @@ public class XMLPackageDescription {
}
}
}
-
+
protected void read() {
PackageDescriptionHandler handler = new PackageDescriptionHandler(this);
-
+
try {
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser parser = factory.newSAXParser();
@@ -236,36 +236,36 @@ public class XMLPackageDescription {
} catch (SAXException ex) {
ex.printStackTrace();
}
-
+
adjust(this);
}
-
+
/* provide an iterator through the children */
protected class Elements implements Enumeration {
-
+
Enumeration e;
protected Elements() {
e = children.elements();
- }
+ }
public boolean hasMoreElements() {
return e.hasMoreElements();
}
public Object nextElement() {
return e.nextElement();
- }
+ }
}
-
+
protected Enumeration elements() {
return new Elements();
}
-
-
+
+
// FIXME: remove it, dump() is for testing only
public void dump() {
dump("");
}
-
+
// FIXME: remove it, dump(String) is for testing only
public void dump(String indent) {
final String space = " ";
@@ -280,7 +280,7 @@ public class XMLPackageDescription {
if (key != null) {
System.out.print(">");
}
-
+
if ((value != null) && (value.length() > 0)) {
String trimmedValue = value.trim();
if (trimmedValue.length() > 60) {
@@ -290,7 +290,7 @@ public class XMLPackageDescription {
System.out.print(trimmedValue);
}
}
-
+
for (Enumeration e = children.elements() ; e.hasMoreElements() ;) {
XMLPackageDescription current = (XMLPackageDescription) e.nextElement();
System.out.println();
@@ -301,7 +301,7 @@ public class XMLPackageDescription {
System.out.print(indent);
}
if (key != null) {
- System.out.print("</" + key + ">");
+ System.out.print("</" + key + ">");
}
}
}