Added ExtXmlSerializer interface.

This commit is contained in:
Ryszard Wiśniewski 2011-05-02 01:44:34 +02:00
parent b11d41aefb
commit 26cdc8299a
3 changed files with 44 additions and 12 deletions

View File

@ -23,8 +23,7 @@ import brut.androlib.res.data.value.ResXmlSerializable;
import brut.androlib.res.decoder.*; import brut.androlib.res.decoder.*;
import brut.androlib.res.decoder.ARSCDecoder.ARSCData; import brut.androlib.res.decoder.ARSCDecoder.ARSCData;
import brut.androlib.res.decoder.ARSCDecoder.FlagsOffset; import brut.androlib.res.decoder.ARSCDecoder.FlagsOffset;
import brut.androlib.res.util.ExtFile; import brut.androlib.res.util.*;
import brut.androlib.res.util.ExtMXSerializer;
import brut.common.BrutException; import brut.common.BrutException;
import brut.directory.*; import brut.directory.*;
import brut.util.*; import brut.util.*;
@ -241,8 +240,9 @@ final public class AndrolibResources {
public ExtMXSerializer getResXmlSerializer() { public ExtMXSerializer getResXmlSerializer() {
ExtMXSerializer serial = new ExtMXSerializer(); ExtMXSerializer serial = new ExtMXSerializer();
serial.setProperty(serial.EXT_PROPERTY_SERIALIZER_INDENTATION, " "); serial.setProperty(ExtXmlSerializer.PROPERTY_SERIALIZER_INDENTATION
serial.setProperty(serial.EXT_PROPERTY_SERIALIZER_LINE_SEPARATOR, , " ");
serial.setProperty(ExtXmlSerializer.PROPERTY_SERIALIZER_LINE_SEPARATOR,
System.getProperty("line.separator")); System.getProperty("line.separator"));
serial.setProperty(ExtMXSerializer.PROPERTY_DEFAULT_ENCODING, "UTF-8"); serial.setProperty(ExtMXSerializer.PROPERTY_DEFAULT_ENCODING, "UTF-8");
return serial; return serial;

View File

@ -23,13 +23,13 @@ import org.xmlpull.mxp1_serializer.MXSerializer;
/** /**
* @author Ryszard Wiśniewski <brut.alll@gmail.com> * @author Ryszard Wiśniewski <brut.alll@gmail.com>
*/ */
public class ExtMXSerializer extends MXSerializer { public class ExtMXSerializer extends MXSerializer implements ExtXmlSerializer {
@Override @Override
public void startDocument(String encoding, Boolean standalone) throws public void startDocument(String encoding, Boolean standalone) throws
IOException, IllegalArgumentException, IllegalStateException { IOException, IllegalArgumentException, IllegalStateException {
super.startDocument(encoding != null ? encoding : mDefaultEncoding, super.startDocument(encoding != null ? encoding : mDefaultEncoding,
standalone); standalone);
super.out.write(lineSeparator); this.newLine();
} }
@Override @Override
@ -55,12 +55,10 @@ public class ExtMXSerializer extends MXSerializer {
} }
} }
public final String EXT_PROPERTY_SERIALIZER_INDENTATION = public ExtXmlSerializer newLine() throws IOException {
PROPERTY_SERIALIZER_INDENTATION; super.out.write(lineSeparator);
public final String EXT_PROPERTY_SERIALIZER_LINE_SEPARATOR = return this;
PROPERTY_SERIALIZER_LINE_SEPARATOR; }
public final static String PROPERTY_DEFAULT_ENCODING = "DEFAULT_ENCODING";
private String mDefaultEncoding; private String mDefaultEncoding;
} }

View File

@ -0,0 +1,34 @@
/**
* Copyright 2011 Ryszard Wiśniewski <brut.alll@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package brut.androlib.res.util;
import java.io.IOException;
import org.xmlpull.v1.XmlSerializer;
/**
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
*/
public interface ExtXmlSerializer extends XmlSerializer {
public ExtXmlSerializer newLine() throws IOException;
public static final String PROPERTY_SERIALIZER_INDENTATION =
"http://xmlpull.org/v1/doc/properties.html#serializer-indentation";
public static final String PROPERTY_SERIALIZER_LINE_SEPARATOR =
"http://xmlpull.org/v1/doc/properties.html#serializer-line-separator";
public static final String PROPERTY_DEFAULT_ENCODING = "DEFAULT_ENCODING";
}