Search in sources :

Example 41 with StringTokenizer

use of java.util.StringTokenizer in project translationstudio8 by heartsome.

the class VTDUtils method dealEscapeQuotes.

/**
	 * 在 XPath 中转义引号(解决在 XPath 中某个字符串同时含有单引号和双引号的情况)
	 * @param xpath
	 * @return ;
	 */
public static String dealEscapeQuotes(String xpath) {
    StringBuffer sb = new StringBuffer();
    if (xpath.indexOf('\'') != -1) {
        StringTokenizer st = new StringTokenizer(xpath, "'\"", true);
        sb.append("concat(");
        while (st.hasMoreTokens()) {
            String token = st.nextToken();
            if (token.equalsIgnoreCase("'")) {
                sb.append("\"");
                sb.append(token);
                sb.append("\"");
            } else {
                sb.append("'");
                sb.append(token);
                sb.append("'");
            }
            if (st.countTokens() != 0) {
                sb.append(",");
            }
        }
        sb.append(")");
    } else {
        sb.append("'");
        sb.append(xpath);
        sb.append("'");
    }
    return sb.toString();
}
Also used : StringTokenizer(java.util.StringTokenizer)

Example 42 with StringTokenizer

use of java.util.StringTokenizer in project translationstudio8 by heartsome.

the class TbMatch method buildWordList.

private static Vector<String> buildWordList(String source, String srcLang) {
    Vector<String> result = new Vector<String>();
    StringTokenizer tk = new StringTokenizer(source, NGrams.SEPARATORS, true);
    while (tk.hasMoreTokens()) {
        result.add(tk.nextToken());
    }
    return result;
}
Also used : StringTokenizer(java.util.StringTokenizer) Vector(java.util.Vector)

Example 43 with StringTokenizer

use of java.util.StringTokenizer in project hibernate-orm by hibernate.

the class BinderHelper method findPropertyByName.

/**
	 * Retrieve the property by path in a recursive way, including IndetifierProperty in the loop
	 * If propertyName is null or empty, the IdentifierProperty is returned
	 */
public static Property findPropertyByName(PersistentClass associatedClass, String propertyName) {
    Property property = null;
    Property idProperty = associatedClass.getIdentifierProperty();
    String idName = idProperty != null ? idProperty.getName() : null;
    try {
        if (propertyName == null || propertyName.length() == 0 || propertyName.equals(idName)) {
            //default to id
            property = idProperty;
        } else {
            if (propertyName.indexOf(idName + ".") == 0) {
                property = idProperty;
                propertyName = propertyName.substring(idName.length() + 1);
            }
            StringTokenizer st = new StringTokenizer(propertyName, ".", false);
            while (st.hasMoreElements()) {
                String element = (String) st.nextElement();
                if (property == null) {
                    property = associatedClass.getProperty(element);
                } else {
                    if (!property.isComposite()) {
                        return null;
                    }
                    property = ((Component) property.getValue()).getProperty(element);
                }
            }
        }
    } catch (MappingException e) {
        try {
            //if we do not find it try to check the identifier mapper
            if (associatedClass.getIdentifierMapper() == null) {
                return null;
            }
            StringTokenizer st = new StringTokenizer(propertyName, ".", false);
            while (st.hasMoreElements()) {
                String element = (String) st.nextElement();
                if (property == null) {
                    property = associatedClass.getIdentifierMapper().getProperty(element);
                } else {
                    if (!property.isComposite()) {
                        return null;
                    }
                    property = ((Component) property.getValue()).getProperty(element);
                }
            }
        } catch (MappingException ee) {
            return null;
        }
    }
    return property;
}
Also used : StringTokenizer(java.util.StringTokenizer) Component(org.hibernate.mapping.Component) Property(org.hibernate.mapping.Property) SyntheticProperty(org.hibernate.mapping.SyntheticProperty) MappingException(org.hibernate.MappingException)

Example 44 with StringTokenizer

use of java.util.StringTokenizer in project j2objc by google.

the class EnvironmentCheck method checkPathForJars.

/**
   * Cheap-o listing of specified .jars found in the classpath. 
   *
   * cp should be separated by the usual File.pathSeparator.  We 
   * then do a simplistic search of the path for any requested 
   * .jar filenames, and return a listing of their names and 
   * where (apparently) they came from.
   *
   * @param cp classpath to search
   * @param jars array of .jar base filenames to look for
   *
   * @return Vector of Hashtables filled with info about found .jars
   * @see #jarNames
   * @see #logFoundJars(Vector, String)
   * @see #appendFoundJars(Node, Document, Vector, String )
   * @see #getApparentVersion(String, long)
   */
protected Vector checkPathForJars(String cp, String[] jars) {
    if ((null == cp) || (null == jars) || (0 == cp.length()) || (0 == jars.length))
        return null;
    Vector v = new Vector();
    StringTokenizer st = new StringTokenizer(cp, File.pathSeparator);
    while (st.hasMoreTokens()) {
        // Look at each classpath entry for each of our requested jarNames
        String filename = st.nextToken();
        for (int i = 0; i < jars.length; i++) {
            if (filename.indexOf(jars[i]) > -1) {
                File f = new File(filename);
                if (f.exists()) {
                    //  the details of that .jar file
                    try {
                        Hashtable h = new Hashtable(2);
                        // Note "-" char is looked for in appendFoundJars
                        h.put(jars[i] + "-path", f.getAbsolutePath());
                        // report the apparent version of the file we've found
                        if (!("xalan.jar".equalsIgnoreCase(jars[i]))) {
                            h.put(jars[i] + "-apparent.version", getApparentVersion(jars[i], f.length()));
                        }
                        v.addElement(h);
                    } catch (Exception e) {
                    /* no-op, don't add it  */
                    }
                } else {
                    Hashtable h = new Hashtable(2);
                    // Note "-" char is looked for in appendFoundJars
                    h.put(jars[i] + "-path", WARNING + " Classpath entry: " + filename + " does not exist");
                    h.put(jars[i] + "-apparent.version", CLASS_NOTPRESENT);
                    v.addElement(h);
                }
            }
        }
    }
    return v;
}
Also used : StringTokenizer(java.util.StringTokenizer) Hashtable(java.util.Hashtable) Vector(java.util.Vector) File(java.io.File)

Example 45 with StringTokenizer

use of java.util.StringTokenizer in project j2objc by google.

the class XSLTAttributeDef method processSTRINGLIST.

/**
   * Process an attribute string of type T_STRINGLIST into
   * a vector of XPath match patterns.
   *
   * @param handler non-null reference to current StylesheetHandler that is constructing the Templates.
   * @param uri The Namespace URI, or an empty string.
   * @param name The local name (without prefix), or empty string if not namespace processing.
   * @param rawName The qualified name (with prefix).
   * @param value a whitespace delimited list of string values.
   *
   * @return A StringVector of the tokenized strings.
   */
StringVector processSTRINGLIST(StylesheetHandler handler, String uri, String name, String rawName, String value) {
    StringTokenizer tokenizer = new StringTokenizer(value, " \t\n\r\f");
    int nStrings = tokenizer.countTokens();
    StringVector strings = new StringVector(nStrings);
    for (int i = 0; i < nStrings; i++) {
        strings.addElement(tokenizer.nextToken());
    }
    return strings;
}
Also used : StringTokenizer(java.util.StringTokenizer) StringVector(org.apache.xml.utils.StringVector)

Aggregations

StringTokenizer (java.util.StringTokenizer)2535 ArrayList (java.util.ArrayList)521 IOException (java.io.IOException)260 HashMap (java.util.HashMap)160 HashSet (java.util.HashSet)150 File (java.io.File)136 BufferedReader (java.io.BufferedReader)112 Map (java.util.Map)103 Set (java.util.Set)91 Iterator (java.util.Iterator)84 List (java.util.List)78 ParseResult (pcgen.rules.persistence.token.ParseResult)68 InputStreamReader (java.io.InputStreamReader)61 URL (java.net.URL)60 Vector (java.util.Vector)53 FileReader (java.io.FileReader)51 NoSuchElementException (java.util.NoSuchElementException)49 MalformedURLException (java.net.MalformedURLException)42 FileInputStream (java.io.FileInputStream)41 CDOMReference (pcgen.cdom.base.CDOMReference)40