use of com.ibm.icu.util.StringTokenizer in project webtools.sourceediting by eclipse.
the class BreakpointProvidersTest method testAdditionalProviders.
/**
* Tests the case of a single provider of additional class patterns
*/
public void testAdditionalProviders() {
// Test
final String pattern = ClassPatternRegistry.getInstance().getClassPattern("org.eclipse.jst.jsp.ui.tests.type");
assertNotNull("Class pattern for 'type' shouldn't be null", pattern);
final String[] expected = new String[] { "*foo", "*bar" };
final StringTokenizer tokenizer = new StringTokenizer(pattern, ",");
final Set tokens = new HashSet(expected.length);
while (tokenizer.hasMoreTokens()) {
tokens.add(tokenizer.nextElement());
}
for (int i = 0; i < expected.length; i++) {
tokens.remove(expected[i]);
}
assertTrue("Class patterns are not equal", tokens.isEmpty());
}
use of com.ibm.icu.util.StringTokenizer in project webtools.sourceediting by eclipse.
the class EscapedTextUtil method getUnescapedText.
public static String getUnescapedText(String test) {
initLookup();
StringBuffer buffer = new StringBuffer();
if (test != null) {
// $NON-NLS-1$
StringTokenizer st = new StringTokenizer(test, "&;", true);
String tok1, tok2, tok3, transString;
while (st.hasMoreTokens()) {
// $NON-NLS-1$
tok1 = tok2 = tok3 = transString = "";
tok1 = st.nextToken();
if (// $NON-NLS-1$
tok1.equals("&") && st.hasMoreTokens()) {
tok2 = st.nextToken();
if (st.hasMoreTokens()) {
tok3 = st.nextToken();
}
}
if (// $NON-NLS-2$ //$NON-NLS-1$
!(transString = fXMLtoJavaLookup.getProperty(tok1 + tok2 + tok3, "")).equals("")) {
buffer.append(transString);
} else {
buffer.append(tok1 + tok2 + tok3);
}
}
return buffer.toString();
}
// $NON-NLS-1$
return "";
}
use of com.ibm.icu.util.StringTokenizer in project webtools.sourceediting by eclipse.
the class WebPropertiesUtil method validateContextRoot.
/**
* @param project
* org.eclipse.core.resources.IProject
*/
/**
* Returns a error message that states whether a context root is valid or not returns null if
* context root is fine
*
* @return java.lang.String
* @param contextRoot
* java.lang.String
*/
public static String validateContextRoot(String contextRoot) {
if (contextRoot == null)
return null;
String errorMessage = null;
String name = contextRoot;
if (name.equals("")) {
// $NON-NLS-1$
// this was added because the error message shouldnt be shown initially. It should be
// shown only if context root field is edited to
errorMessage = ResourceHandler.StaticWebProjectWizardBasePage_Page_Title;
// errorMessage = ProjectSupportResourceHandler.getString("Context_Root_cannot_be_empty_2"); //$NON-NLS-1$
return errorMessage;
}
if (name.trim().equals(name)) {
// $NON-NLS-1$
StringTokenizer stok = new StringTokenizer(name, ".");
outer: while (stok.hasMoreTokens()) {
String token = stok.nextToken();
for (int i = 0; i < token.length(); i++) {
if (!(token.charAt(i) == '_') && !(token.charAt(i) == '-') && !(token.charAt(i) == '/') && Character.isLetterOrDigit(token.charAt(i)) == false) {
if (Character.isWhitespace(token.charAt(i))) {
// Removed because context roots can contain white space
// errorMessage =
// ResourceHandler.getString("_Context_root_cannot_conta_UI_");//$NON-NLS-1$
// = " Context root cannot contain whitespaces."
} else {
errorMessage = ResourceHandler.StaticWebProjectWizardBasePage_Page_Title;
// errorMessage = ProjectSupportResourceHandler.getString("The_character_is_invalid_in_a_context_root", new Object[]{(new Character(token.charAt(i))).toString()}); //$NON-NLS-1$
break outer;
}
}
}
}
} else
// en/ end of if(name.trim
errorMessage = ResourceHandler.StaticWebProjectWizardBasePage_Page_Title;
return errorMessage;
}
use of com.ibm.icu.util.StringTokenizer in project webtools.sourceediting by eclipse.
the class JSPTranslator method addImports.
/**
* Pass in a comma delimited list of import values, appends each to the
* final result buffer
*
* @param value
* a comma delimited list of imports
*/
protected void addImports(String value, boolean addToMap) {
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=81687
// added the "addToMap" parameter to exclude imports originating
// from included JSP files to be added to the jsp<->java mapping
// $NON-NLS-1$
StringTokenizer st = new StringTokenizer(value, ",", false);
// $NON-NLS-1$
String tok = "";
// String appendage = ""; //$NON-NLS-1$
while (st.hasMoreTokens()) {
tok = st.nextToken();
appendImportToBuffer(tok, fCurrentNode, addToMap);
}
}
use of com.ibm.icu.util.StringTokenizer in project webtools.sourceediting by eclipse.
the class PageDirectiveAdapterImpl method getMimeTypeFromContentTypeValue.
/**
* parses the full contentType value into its two parts the contentType,
* and the charset, if present. Note: this method is a lightly modified
* version of a method in AbstractHeadParser. There, we're mostly
* interested in the charset part of contentTypeValue. Here, we're mostly
* interested in the mimeType part.
*/
private String getMimeTypeFromContentTypeValue(String contentTypeValue) {
if (contentTypeValue == null)
return null;
String cleanContentTypeValue = StringUtils.stripNonLetterDigits(contentTypeValue);
// $NON-NLS-1$
StringTokenizer tokenizer = new StringTokenizer(cleanContentTypeValue, ";= \t\n\r\f");
int tLen = tokenizer.countTokens();
// if contains encoding should have three tokens, the mimetype, the
// word 'charset', and the encoding value
String[] tokens = new String[tLen];
int j = 0;
while (tokenizer.hasMoreTokens()) {
tokens[j] = tokenizer.nextToken();
j++;
}
//
// Following is the common form for target expression
// <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
// But apparrently is also valid without the content type there,
// just the charset, as follows:
// <META http-equiv="Content-Type" content="charset=UTF-8">
// So we'll loop through tokens and key off of 'charset'
int charsetPos = -1;
for (int i = 0; i < tokens.length; i++) {
if (tokens[i].equalsIgnoreCase(STR_CHARSET)) {
charsetPos = i;
break;
}
}
// String charset = null;
String contentType = null;
if (charsetPos > -1) {
// case where charset was present
// int charsetValuePos = charsetPos + 1;
// if (charsetValuePos < tokens.length) {
// charset = tokens[charsetValuePos];
// }
int contentTypeValuePos = charsetPos - 1;
if (contentTypeValuePos > -1) {
contentType = tokens[contentTypeValuePos];
}
} else {
// a value, we assume its the contentType value
if (tokens.length > 0) {
contentType = tokens[0];
}
}
return contentType;
}
Aggregations