protected Object readResolve() throws InvalidObjectException { // return the singleton instead of deserialized object. try { // backward compatibility with JDK1.3. we can't rely on the // order of inner classes if( this.getClass()==backwardCompatibiliyHook1.getClass() ) return thePreserve; if( this.getClass()==backwardCompatibiliyHook2.getClass() ) return theCollapse; if( this.getClass()==backwardCompatibiliyHook3.getClass() ) return theReplace; return get(getName()); } catch (DatatypeException bte) { throw new InvalidObjectException("Unknown Processing Mode"); } }
public static String replace(String str) { return theReplace.process(str); } public static String collapse(String str) {
public final String getCollapsedAttribute( String attrName ) { String s = getAttribute(attrName); if(s==null) return null; return WhiteSpaceProcessor.collapse(s); }
/** test behavior of preserve */ public void testPreserve() throws DatatypeException { WhiteSpaceProcessor target = WhiteSpaceProcessor.get("preserve"); String[] tests = new String[] { "test", " a b c ", "\r\n \ta bb \t\t c \r\r\n\r " }; for( int i=0; i<tests.length; i++ ) assertEquals( tests[i], target.process(tests[i]) ); }
public String process(String text) { final int len = text.length(); StringBuffer result = new StringBuffer(len); for (int i = 0; i < len; i++) { char ch = text.charAt(i); if (super.isWhiteSpace(ch)) result.append(' '); else result.append(ch); } return result.toString(); } int tightness() {
WhiteSpaceFacet( String nsUri, String typeName, XSDatatypeImpl baseType, TypeIncubator facets ) throws DatatypeException { this(nsUri,typeName, baseType, WhiteSpaceProcessor.get( (String)facets.getFacet(FACET_WHITESPACE)), facets.isFixed(FACET_WHITESPACE) ); }
WhiteSpaceFacet( String nsUri, String typeName, XSDatatypeImpl baseType, WhiteSpaceProcessor proc, boolean _isFixed ) throws DatatypeException { super(nsUri,typeName, baseType, FACET_WHITESPACE, _isFixed,proc); // loosened facet check if( baseType.whiteSpace.tightness() > this.whiteSpace.tightness() ) { XSDatatype d; d=baseType.getFacetObject(FACET_WHITESPACE); if(d==null) d = getConcreteType(); throw new DatatypeException( localize( ERR_LOOSENED_FACET, FACET_WHITESPACE, d.displayName() )); } // consistency with minLength/maxLength is checked in XSDatatypeImpl.derive method. }
/** tests behavior of replace */ public void testReplace() throws DatatypeException { WhiteSpaceProcessor target = WhiteSpaceProcessor.get("replace"); assertEquals( target.process( "test"), "test"); assertEquals( target.process( " a b c "), " a b c "); assertEquals( target.process( "\r\n \ta bb \t\t c \r\r\n\r "), " a bb c "); }
public String process(String text) { final int len = text.length(); StringBuffer result = new StringBuffer(len); for (int i = 0; i < len; i++) { char ch = text.charAt(i); if (super.isWhiteSpace(ch)) result.append(' '); else result.append(ch); } return result.toString(); } int tightness() {
WhiteSpaceFacet( String nsUri, String typeName, XSDatatypeImpl baseType, TypeIncubator facets ) throws DatatypeException { this(nsUri,typeName, baseType, WhiteSpaceProcessor.get( (String)facets.getFacet(FACET_WHITESPACE)), facets.isFixed(FACET_WHITESPACE) ); }
WhiteSpaceFacet( String nsUri, String typeName, XSDatatypeImpl baseType, WhiteSpaceProcessor proc, boolean _isFixed ) throws DatatypeException { super(nsUri,typeName, baseType, FACET_WHITESPACE, _isFixed,proc); // loosened facet check if( baseType.whiteSpace.tightness() > this.whiteSpace.tightness() ) { XSDatatype d; d=baseType.getFacetObject(FACET_WHITESPACE); if(d==null) d = getConcreteType(); throw new DatatypeException( localize( ERR_LOOSENED_FACET, FACET_WHITESPACE, d.displayName() )); } // consistency with minLength/maxLength is checked in XSDatatypeImpl.derive method. }
public static String collapse(String str) { return theCollapse.process(str); }
protected Object readResolve() throws InvalidObjectException { // return the singleton instead of deserialized object. try { // backward compatibility with JDK1.3. we can't rely on the // order of inner classes if( this.getClass()==backwardCompatibiliyHook1.getClass() ) return thePreserve; if( this.getClass()==backwardCompatibiliyHook2.getClass() ) return theCollapse; if( this.getClass()==backwardCompatibiliyHook3.getClass() ) return theReplace; return get(getName()); } catch (DatatypeException bte) { throw new InvalidObjectException("Unknown Processing Mode"); } }
/** tests behavior of collapse */ public void testCollapse() throws DatatypeException { WhiteSpaceProcessor target = WhiteSpaceProcessor.get("collapse"); assertEquals( target.process( "test"), "test"); assertEquals( target.process( " a b c "), "a b c"); assertEquals( target.process( "\r\n \ta bb \t\t c \r\r\n\r "), "a bb c"); assertEquals( target.process( "abc "), "abc"); assertEquals( target.process( "abc "), "abc"); }
public final String getCollapsedAttribute( String attrName ) { String s = getAttribute(attrName); if(s==null) return null; return WhiteSpaceProcessor.collapse(s); }
public String process(String text) { final int len = text.length(); StringBuffer result = new StringBuffer(len); for (int i = 0; i < len; i++) { char ch = text.charAt(i); if (super.isWhiteSpace(ch)) result.append(' '); else result.append(ch); } return result.toString(); } int tightness() {
WhiteSpaceFacet( String nsUri, String typeName, XSDatatypeImpl baseType, TypeIncubator facets ) throws DatatypeException { this(nsUri,typeName, baseType, WhiteSpaceProcessor.get( (String)facets.getFacet(FACET_WHITESPACE)), facets.isFixed(FACET_WHITESPACE) ); }
WhiteSpaceFacet( String nsUri, String typeName, XSDatatypeImpl baseType, WhiteSpaceProcessor proc, boolean _isFixed ) throws DatatypeException { super(nsUri,typeName, baseType, FACET_WHITESPACE, _isFixed,proc); // loosened facet check if( baseType.whiteSpace.tightness() > this.whiteSpace.tightness() ) { XSDatatype d; d=baseType.getFacetObject(FACET_WHITESPACE); if(d==null) d = getConcreteType(); throw new DatatypeException( localize( ERR_LOOSENED_FACET, FACET_WHITESPACE, d.displayName() )); } // consistency with minLength/maxLength is checked in XSDatatypeImpl.derive method. }
public static String replace(String str) { return theReplace.process(str); } public static String collapse(String str) {
protected Object readResolve() throws InvalidObjectException { // return the singleton instead of deserialized object. try { // backward compatibility with JDK1.3. we can't rely on the // order of inner classes if( this.getClass()==backwardCompatibiliyHook1.getClass() ) return thePreserve; if( this.getClass()==backwardCompatibiliyHook2.getClass() ) return theCollapse; if( this.getClass()==backwardCompatibiliyHook3.getClass() ) return theReplace; return get(getName()); } catch (DatatypeException bte) { throw new InvalidObjectException("Unknown Processing Mode"); } }