Example usage for java.util StringTokenizer StringTokenizer

List of usage examples for java.util StringTokenizer StringTokenizer

Introduction

In this page you can find the example usage for java.util StringTokenizer StringTokenizer.

Prototype

public StringTokenizer(String str) 

Source Link

Document

Constructs a string tokenizer for the specified string.

Usage

From source file:biblivre3.z3950.BiblivrePrefixString.java

@Override
public InternalModelRootNode toInternalQueryModel(ApplicationContext ctx) throws InvalidQueryException {
    if (StringUtils.isBlank(queryAttr) || StringUtils.isBlank(queryTerms)) {
        throw new InvalidQueryException("Null prefix string");
    }//  w  w  w .  j  a  v a  2s.  c  o m
    try {
        if (internalModel == null) {
            internalModel = new InternalModelRootNode();
            InternalModelNamespaceNode node = new InternalModelNamespaceNode();
            node.setAttrset(DEFAULT_ATTRSET);
            internalModel.setChild(node);
            AttrPlusTermNode attrNode = new AttrPlusTermNode();
            final String attrValue = "1." + queryAttr;
            attrNode.setAttr(DEFAULT_ATTRTYPE, new AttrValue(null, attrValue));
            Vector terms = new Vector();
            StringTokenizer tokenizer = new StringTokenizer(queryTerms);
            while (tokenizer.hasMoreElements()) {
                terms.add(tokenizer.nextElement());
            }
            if (terms.size() > 1) {
                attrNode.setTerm(terms);
            } else if (terms.size() == 1) {
                attrNode.setTerm(terms.get(0));
            } else {
                throw new PrefixQueryException("No Terms");
            }
            node.setChild(attrNode);
        }
    } catch (Exception e) {
        throw new InvalidQueryException(e.getMessage());
    }
    return internalModel;
}

From source file:Ch5Persistent.java

private void load() {
    File file = new File(FILE_NAME);
    if (file.exists()) {
        try {/*from  w w w  .  jav a 2 s . c  o m*/
            BufferedReader reader = new BufferedReader(new FileReader(file));
            String currLine = reader.readLine();

            StringTokenizer tokenizer = new StringTokenizer(currLine);
            tokenizer.nextToken(); //discard START_TEXT_MARKER
            String contentLengthString = tokenizer.nextToken();
            int contentLength = Integer.parseInt(contentLengthString);

            readContent(reader, contentLength);

            //find the beginning of the styles section
            while (((currLine = reader.readLine()) != null) && !START_STYLES_MARK.equals(currLine))
                ;

            readStyles(reader, currLine);
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

From source file:cn.vlabs.clb.server.ui.frameservice.pdf.PdfConvertAdapter.java

private void processLine(String l, Properties props) {
    // Look for comments.
    int indPound = l.indexOf('#');
    // Remove comments and whitespace.
    String line = (indPound == -1) ? l.trim() : l.substring(0, indPound).trim();
    if (line.length() != 0) {
        StringTokenizer stl = new StringTokenizer(line);
        String key = stl.nextToken();
        String value = stl.nextToken();
        while (stl.hasMoreTokens()) {
            value += " " + stl.nextToken();
        }//  w  w w  .ja v  a  2 s .  c om
        // Fill in the appropriate property.
        props.setProperty(key, value);
    }
}