Methods Summary |
---|
protected static void | filesetElement(org.w3c.dom.Node filesetNode, java.util.ArrayList fileList)
NamedNodeMap attributes = filesetNode.getAttributes();
Node includes = attributes.getNamedItem("includes");
if (includes != null) {
StringTokenizer tok = new StringTokenizer(includes.getNodeValue());
while (tok.hasMoreTokens()) {
fileList.add(tok.nextToken());
}
}
ArrayList removeList = new ArrayList();
Node excludes = attributes.getNamedItem("excludes");
if (excludes != null) {
StringTokenizer tok = new StringTokenizer(excludes.getNodeValue());
while (tok.hasMoreTokens()) {
removeList.add(tok.nextToken());
}
}
for (int i = 0; i < fileList.size(); i++) {
if (removeList.contains(fileList.get(i))) {
fileList.remove(i--);
}
}
|
public static void | main(java.lang.String[] args)
if (args.length != 1) {
System.out.println("usage: MakeZipProto xmlFile");
} else {
String xmlFile = args[0];
try {
parseXML(xmlFile);
//translate(inFile, outFile);
} catch (Exception ex) {
ex.printStackTrace();
}
}
|
public static java.lang.String | parse(java.lang.String line)
String result = line.trim();
//skip empty lines
if (result.length() == 0) {
return null;
}
//skip comments
if (result.startsWith("#")) {
return null;
}
//skip directories
if (result.startsWith("d ")) {
return null;
}
//skip included packaging files
if (result.startsWith("i ")) {
return null;
}
//process normal files
if (result.startsWith("f ")) {
return parseFile(result);
}
return result;
|
public static java.lang.String | parseFile(java.lang.String line)
StringTokenizer tok = new StringTokenizer(line);
tok.nextToken();
tok.nextToken();
String result = tok.nextToken().replaceAll("\\$ASINSTDIR/", "");
int pos = result.indexOf("=");
if (pos > 0) {
return result.substring(pos + 1);
}
return result;
|
protected static void | parseXML(java.lang.String fileName)
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
FileInputStream source = new FileInputStream(fileName);
Document document = builder.parse(source);
NodeList nodeList = document.getElementsByTagName("zipfile");
if (nodeList != null) {
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
zipfileElement(node);
}
}
|
protected static java.util.ArrayList | readInputFile(java.lang.String in)
ArrayList result = new ArrayList();
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(in));
String line = null;
String newLine = null;
while (true) {
line = reader.readLine();
if (line == null) {
break;
}
newLine = parse(line);
if (newLine != null) {
result.add(newLine);
}
}
return result;
} finally {
try {
if (reader != null) {
reader.close();
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
|
protected static void | writeOutputFile(java.lang.String out, java.util.ArrayList fileList)
BufferedWriter writer = null;
try {
writer = new BufferedWriter(new FileWriter(out, false));
for (int i = 0; i < fileList.size(); i++) {
writer.write((String)fileList.get(i));
writer.newLine();
}
} finally {
try {
if (writer != null) {
writer.close();
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
|
protected static void | zipfileElement(org.w3c.dom.Node zipfileNode)
NamedNodeMap attributes = zipfileNode.getAttributes();
String inputFile = attributes.getNamedItem("input").getNodeValue();
System.out.println("inputFile = " + inputFile);
String outputFile = attributes.getNamedItem("output").getNodeValue();
System.out.println("output = " + outputFile);
ArrayList fileList = readInputFile(inputFile);
for (int i = 0; i < fileList.size(); i++) {
System.out.println("fileList before " + i + " = " +
fileList.get(i));
}
NodeList children = zipfileNode.getChildNodes();
for (int j = 0; j < children.getLength(); j++) {
Node childNode = children.item(j);
if (childNode.getNodeName().equals("fileset")) {
filesetElement(childNode, fileList);
}
}
for (int i = 0; i < fileList.size(); i++) {
System.out.println("fileList after " + i + " = " +
fileList.get(i));
}
writeOutputFile(outputFile, fileList);
|