/* * @(#)$Id: StringState.java,v 1.4 2001/10/18 23:52:14 Bear Exp $ * * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved. * * This software is the proprietary information of Sun Microsystems, Inc. * Use is subject to license terms. * */ package com.sun.msv.reader.trex.classic; import com.sun.msv.grammar.Expression; import com.sun.msv.reader.ExpressionWithoutChildState; import com.sun.msv.util.StringPair; import com.sun.msv.datatype.xsd.StringType; import com.sun.msv.datatype.xsd.TokenType; import com.sun.msv.datatype.xsd.WhiteSpaceProcessor; /** * parses <string> pattern. * * @author <a href="mailto:kohsuke.kawaguchi@eng.sun.com">Kohsuke KAWAGUCHI</a> */ public class StringState extends ExpressionWithoutChildState { protected final StringBuffer text = new StringBuffer(); public void characters( char[] buf, int from, int len ) { text.append(buf,from,len); } public void ignorableWhitespace( char[] buf, int from, int len ) { text.append(buf,from,len); } protected Expression makeExpression() { if("preserve".equals(startTag.getAttribute("whiteSpace"))) return reader.pool.createValue( StringType.theInstance, new StringPair("","string"), text.toString() ); else return reader.pool.createValue( TokenType.theInstance, new StringPair("","token"), WhiteSpaceProcessor.collapse(text.toString()) ); // masquerade RELAX NG built-in datatypes } }