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();
}
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;
}
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;
}
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;
}
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;
}
Aggregations