< prev index next >

src/java.xml.bind/share/classes/com/sun/xml/internal/txw2/Document.java

Print this page




 269      * Used by {@link #newPrefix()}.
 270      */
 271     private final StringBuilder prefixSeed = new StringBuilder("ns");
 272 
 273     private int prefixIota = 0;
 274 
 275     /**
 276      * Allocates a new unique prefix.
 277      */
 278     private String newPrefix() {
 279         prefixSeed.setLength(2);
 280         prefixSeed.append(++prefixIota);
 281         return prefixSeed.toString();
 282     }
 283 
 284     /**
 285      * Replaces dummy prefixes in the value to the real ones
 286      * by using {@link #activeNamespaces}.
 287      *
 288      * @return
 289      *      the buffer passed as the <tt>buf</tt> parameter.
 290      */
 291     private StringBuilder fixPrefix(StringBuilder buf) {
 292         assert activeNamespaces!=null;
 293 
 294         int i;
 295         int len=buf.length();
 296         for(i=0;i<len;i++)
 297             if( buf.charAt(i)==MAGIC )
 298                 break;
 299         // typically it doens't contain any prefix.
 300         // just return the original buffer in that case
 301         if(i==len)
 302             return buf;
 303 
 304         while(i<len) {
 305             char uriIdx = buf.charAt(i+1);
 306             NamespaceDecl ns = activeNamespaces;
 307             while(ns!=null && ns.uniqueId!=uriIdx)
 308                 ns=ns.next;
 309             if(ns==null)




 269      * Used by {@link #newPrefix()}.
 270      */
 271     private final StringBuilder prefixSeed = new StringBuilder("ns");
 272 
 273     private int prefixIota = 0;
 274 
 275     /**
 276      * Allocates a new unique prefix.
 277      */
 278     private String newPrefix() {
 279         prefixSeed.setLength(2);
 280         prefixSeed.append(++prefixIota);
 281         return prefixSeed.toString();
 282     }
 283 
 284     /**
 285      * Replaces dummy prefixes in the value to the real ones
 286      * by using {@link #activeNamespaces}.
 287      *
 288      * @return
 289      *      the buffer passed as the {@code buf} parameter.
 290      */
 291     private StringBuilder fixPrefix(StringBuilder buf) {
 292         assert activeNamespaces!=null;
 293 
 294         int i;
 295         int len=buf.length();
 296         for(i=0;i<len;i++)
 297             if( buf.charAt(i)==MAGIC )
 298                 break;
 299         // typically it doens't contain any prefix.
 300         // just return the original buffer in that case
 301         if(i==len)
 302             return buf;
 303 
 304         while(i<len) {
 305             char uriIdx = buf.charAt(i+1);
 306             NamespaceDecl ns = activeNamespaces;
 307             while(ns!=null && ns.uniqueId!=uriIdx)
 308                 ns=ns.next;
 309             if(ns==null)


< prev index next >