diff --git a/src/brut/androlib/res/data/ResType.java b/src/brut/androlib/res/data/ResType.java index 962b59c3..4a45d961 100644 --- a/src/brut/androlib/res/data/ResType.java +++ b/src/brut/androlib/res/data/ResType.java @@ -26,7 +26,6 @@ import java.util.*; */ public final class ResType { private final String mName; -// private final TypeConfig mConfig; private final Map mResSpecs = new LinkedHashMap(); @@ -56,132 +55,6 @@ public final class ResType { } return spec; } -// -// public void decode(AndrolibResources andRes, ResXmlSerializer serial, -// Directory in, Directory out) throws AndrolibException { -// decodeFiles(andRes, serial, in, out); -// decodeValues(andRes, serial, out); -// } -// -// public void decodeFiles(AndrolibResources andRes, ResXmlSerializer serial, -// Directory in, Directory out) throws AndrolibException { -// if (! mConfig.isFile) { -// return; -// } -// -// ResFileDecoder decoder = andRes.getResFileDecoder(serial); -// -// for (ResResSpec res : listResources()) { -// for (ResResource value : res.listResources()) { -// if (! value.isStrVal()) { -// continue; -// } -// String fileName = value.getStrVal(); -// if (! fileName.startsWith("res/")) { -// throw new AndrolibException( -// "Invalid res file location: " + fileName); -// } -// decoder.decode(in, fileName.substring(4), out, -// value.getFilePath()); -// } -// } -// } -// -// public void decodeValues(AndrolibResources andRes, ResXmlSerializer serial, -// Directory out) throws AndrolibException { -// if (! mConfig.isValues) { -// return; -// } -// -// boolean oldEscapeRefs = serial.setEscapeRefs(false); -// -// for (Entry> entry : -// groupValuesByConfig().entrySet()) { -// ResConfigFlags config = entry.getKey(); -// String filePath = "values" + config.getQualifiers() + "/" -// + mConfig.valuesFileName + ".xml"; -// -// try { -// serial.setOutput(out.getFileOutput(filePath), null); -// serial.startDocument(null, null); -// serial.startTag(null, "resources"); -// -// for (ResResource value : entry.getValue()) { -// if (mName.equals("array")) { -// decodeArrayValue(serial, value); -// } else { -// serial.startTag(null, mConfig.valuesTagName); -// serial.attribute( -// null, "name", value.getResSpec().getName()); -// -// if (mName.equals("style")) { -// decodeStyleValue(serial, value); -// } else if (mName.equals("attr")) { -// decodeAttrValue(serial, value); -// } else { -// decodeSimpleValue(serial, value); -// } -// -// serial.endTag(null, mConfig.valuesTagName); -// } -// } -// -// serial.endTag(null, "resources"); -// serial.endDocument(); -// } catch (IOException ex) { -// throw new AndrolibException( -// "Could not decode values for:" + filePath, ex); -// } catch (DirectoryException ex) { -// throw new AndrolibException( -// "Could not decode values for:" + filePath, ex); -// } -// } -// -// serial.setEscapeRefs(oldEscapeRefs); -// } -// -// private void decodeSimpleValue(ResXmlSerializer serial, ResResource value) -// throws IOException, AndrolibException { -// serial.text(value.toResXMlText()); -// } -// -// private void decodeArrayValue(ResXmlSerializer serial, ResResource value) -// throws IOException, AndrolibException { -// String arrType = value.getBag().getType(); -// String tagName = (arrType != null ? arrType + "-" : "") + "array"; -// serial.startTag(null, tagName); -// serial.attribute( -// null, "name", value.getResSpec().getName()); -// for (ResResource item : value.getBag().getItems().values()) { -// serial.startTag(null, "item"); -// serial.text(item.getStrVal()); -// serial.endTag(null, "item"); -// } -// serial.endTag(null, tagName); -// } -// -// private void decodeAttrValue(ResXmlSerializer serial, ResResource value) -// throws IOException, AndrolibException { -// -// } -// -// private void decodeStyleValue(ResXmlSerializer serial, ResResource value) -// throws IOException, AndrolibException { -// ResBag bag = value.getBag(); -// if (bag.getParent().id != 0) { -// serial.attribute(null, "parent", bag.getParentRes() -// .getResReference(false, mPackage.getName())); -// -// for (Entry entry : bag.getItems().entrySet()) { -// serial.startTag(null, "item"); -// -// ResResSpec attr = mResTable.getResSpec(entry.getKey()); -// serial.attribute(null, "name", attr.getResReference(false, mPackage.getName(), true).substring(1)); -// serial.text(attr.getDefaultResource().decodeAttrValue(entry.getValue().getAsString(), false, mPackage.getName())); -// serial.endTag(null, "item"); -// } -// } -// } public void addResSpec(ResResSpec spec) throws AndrolibException { @@ -195,94 +68,4 @@ public final class ResType { public String toString() { return mName; } -// -// private Map> groupValuesByConfig() { -// Map> grouped = -// new LinkedHashMap>(); -// -// for (ResResSpec res : listResSpecs()) { -// for (ResResource value : res.listResources()) { -// ResConfigFlags config = value.getConfig().getFlags(); -// Set values = grouped.get(config); -// if (values == null) { -// values = new LinkedHashSet(); -// grouped.put(config, values); -// } -// values.add(value); -// } -// } -// -// return grouped; -// } -// -// -// public static ResType factory(String name, ResTable resTable, -// ResPackage package_) throws AndrolibException { -// if (typesConfig == null) { -// loadTypesConfig(); -// } -// TypeConfig config = typesConfig.get(name); -// if (config == null) { -// throw new AndrolibException("Invalid type name: " + name); -// } -// return new ResType(name, config, resTable, package_); -// } -// -// private static void loadTypesConfig() { -// typesConfig = new HashMap(); -// typesConfig.put("anim", new FileTypeConfig()); -// typesConfig.put("drawable", new FileTypeConfig()); -// typesConfig.put("layout", new FileTypeConfig()); -// typesConfig.put("menu", new FileTypeConfig()); -// typesConfig.put("raw", new FileTypeConfig()); -// typesConfig.put("xml", new FileTypeConfig()); -// -// typesConfig.put("attr", new ValuesTypeConfig("attrs", "attr")); -// typesConfig.put("dimen", new ValuesTypeConfig("dimens", "dimen")); -// typesConfig.put("string", new ValuesTypeConfig("strings", "string")); -// typesConfig.put("integer", new ValuesTypeConfig("integers", "integer")); -// typesConfig.put("array", new ValuesTypeConfig("arrays", "array")); -// typesConfig.put("style", new ValuesTypeConfig("styles", "style")); -// -// typesConfig.put("color", new TypeConfig(true, true, "colors", "color")); -// -// typesConfig.put("bool", new TypeConfig()); -// typesConfig.put("id", new TypeConfig()); -//// typesConfig.put("integer", new TypeConfig()); -// typesConfig.put("plurals", new TypeConfig()); -// } -// -// private static Map typesConfig; -// -// -// public static class TypeConfig { -// public final boolean isFile; -// public final boolean isValues; -// public final String valuesFileName; -// public final String valuesTagName; -// -// public TypeConfig() { -// this(false, false, null, null); -// } -// -// public TypeConfig(boolean isFile, boolean isValues, -// String valuesFileName, String valuesTagName) { -// this.isFile = isFile; -// this.isValues = isValues; -// this.valuesFileName = valuesFileName; -// this.valuesTagName = valuesTagName; -// } -// } -// -// public static class FileTypeConfig extends TypeConfig { -// public FileTypeConfig() { -// super(true, false, null, null); -// } -// } -// -// public static class ValuesTypeConfig extends TypeConfig { -// public ValuesTypeConfig(String fileName, String tagName) { -// super(false, true, fileName, tagName); -// } -// } }