9 package javolution.xml.internal.stream;
11 import java.io.IOException;
12 import java.io.OutputStream;
13 import java.io.OutputStreamWriter;
14 import java.io.UnsupportedEncodingException;
15 import java.io.Writer;
184 public void setOutput(OutputStream out, String encoding)
186 if (encoding.equals(
"UTF-8") || encoding.equals(
"utf-8")
187 || encoding.equals(
"ASCII")) {
192 setOutput(
new OutputStreamWriter(out, encoding));
193 }
catch (UnsupportedEncodingException e) {
209 throw new IllegalStateException(
"Writer not closed or reset");
307 if (localName ==
null)
315 if (localName ==
null)
317 if (namespaceURI ==
null)
325 if (localName ==
null)
327 if (namespaceURI ==
null)
374 for (
int i = 1; i <
_nesting; i++) {
412 }
catch (IOException e) {
420 if (localName ==
null)
429 CharSequence localName, CharSequence value)
431 if (localName ==
null)
435 if (namespaceURI ==
null)
442 CharSequence localName, CharSequence value)
444 if (localName ==
null)
448 if (namespaceURI ==
null)
458 if ((prefix ==
null) || (prefix.length() == 0)
463 throw new IllegalStateException(
"No open start element");
527 "DOCTYPE declaration (DTD) when not in document root (prolog)");
555 if (version !=
null) {
561 if (encoding !=
null) {
597 public void setPrefix(CharSequence prefix, CharSequence uri)
609 public Object
getProperty(String name)
throws IllegalArgumentException {
623 throw new IllegalArgumentException(
"Property: " + name
654 if ((namespaceURI !=
null)
658 }
else if (prefix ==
null) {
662 +
" not bound and repairing namespaces disabled");
664 if (prefix.length() > 0) {
675 CharSequence namespaceURI, CharSequence localName,
678 throw new IllegalStateException(
"No open start element");
682 if ((namespaceURI !=
null)
686 }
else if (prefix ==
null) {
690 +
" not bound and repairing namespaces disabled");
692 if (prefix.length() > 0) {
740 for (
int i = i0; i < i2; i++) {
769 if ((prefixForURI !=
null)
770 && ((prefix ==
null) || prefixForURI.
equals(prefix)))
772 if ((prefix ==
null) || (prefix.length() == 0)) {
785 final int newLength = oldLength * 2;
789 System.arraycopy(
_qNames, 0, tmp, 0, oldLength);
791 for (
int i = oldLength; i < newLength; i++) {
800 write(str, 0, str.length(),
false);
804 write(tb, 0, tb.length(),
false);
809 write(csq, 0, csq.length(),
false);
813 write(csq, 0, csq.length(),
true);
816 private final void write(Object csq,
int start,
int length,
819 if (csq instanceof String) {
820 ((String) csq).getChars(start, start + length,
_buffer,
_index);
835 int end =
_index + length;
836 for (
int i =
_index; i < end; i++) {
852 write(csq, start, length, escapeMarkup);
854 int half = length >> 1;
855 write(csq, start, half, escapeMarkup);
856 write(csq, start + half, length - half, escapeMarkup);
861 private static void getChars(CharSequence csq,
int start,
int end,
862 char dest[],
int destPos) {
863 for (
int i = start, j = destPos; i < end;) {
864 dest[j++] = csq.charAt(i++);
872 int blockStart = start;
873 for (
int i = start; i < end;) {
878 int blockLength = i - blockStart - 1;
879 if (blockLength > 0) {
901 _writer.write((
char) (
'0' + c / 10));
902 _writer.write((
char) (
'0' + c % 10));
907 int blockLength = end - blockStart;
908 if (blockLength > 0) {
911 }
catch (IOException e) {
932 }
catch (IOException e) {