/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Coordinates the entire writing process.
*
* @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
*/
public final class Document {
/**
* Set to true once we invoke {@link XmlSerializer#startDocument()}.
*
* <p>
* This is so that we can defer the writing as much as possible.
*/
private boolean started=false;
/**
* Currently active writer.
*
* <p>
* This points to the last written token.
*/
/**
* Used to generate unique namespace prefix.
*/
/**
* Used to keep track of in-scope namespace bindings declared in ancestors.
*/
/**
* Remembers the namespace declarations of the last unclosed start tag,
* so that we can fix up dummy prefixes in {@link Pcdata}.
*/
}
void flush() {
}
current = new StartDocument();
}
/**
* Defines additional user object -> string conversion logic.
*
* <p>
* Applications can add their own {@link DatatypeWriter} so that
* application-specific objects can be turned into {@link String}
* for output.
*
* @param dw
* The {@link DatatypeWriter} to be added. Must not be null.
*/
}
/**
* Performs the output as much as possible
*/
void run() {
while(true) {
return;
}
}
/**
* Appends the given object to the end of the given buffer.
*
* @param nsResolver
* use
*/
throw new IllegalArgumentException("argument contains null");
return;
}
return;
}
while(c!=null) {
return;
}
c = c.getSuperclass();
}
// if nothing applies, just use toString
}
// I wanted to hide those write method from users
public void onStartDocument() {
// the startDocument token is used as the sentry, so this method shall never
// be called.
// out.startDocument() is invoked when we write the start tag of the root element.
throw new IllegalStateException();
}
public void onEndDocument() {
out.endDocument();
}
public void onEndTag() {
}
if(activeNamespaces!=null)
}
if(activeNamespaces!=null)
}
if(activeNamespaces!=null)
}
public void onStartTag(String nsUri, String localName, Attribute attributes, NamespaceDecl namespaces) {
if(!started) {
started = true;
out.startDocument();
}
// declare the explicitly bound namespaces
; // already declared
else {
// declare this new binding
}
}
}
// then use in-scope namespace to assign prefixes to others
else {
if(p==null) {
// assign a new one
;
}
}
}
}
// the first namespace decl must be the one for the element
// declare namespaces
}
// writeBody attributes
}
}
};
/**
* Used by {@link #newPrefix()}.
*/
/**
* Allocates a new unique prefix.
*/
return prefixSeed.toString();
}
/**
* Replaces dummy prefixes in the value to the real ones
* by using {@link #activeNamespaces}.
*
* @return
* the buffer passed as the <tt>buf</tt> parameter.
*/
assert activeNamespaces!=null;
int i;
for(i=0;i<len;i++)
break;
// typically it doens't contain any prefix.
// just return the original buffer in that case
if(i==len)
return buf;
while(i<len) {
int length = 2;
length=3;
}
i++;
}
return buf;
}
/**
* The first char of the dummy prefix.
*/
char assignNewId() {
return (char)iota++;
}
}