Search in sources :

Example 46 with StringTokenizer

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());
}
Also used : StringTokenizer(com.ibm.icu.util.StringTokenizer) HashSet(java.util.HashSet) Set(java.util.Set) HashSet(java.util.HashSet)

Example 47 with StringTokenizer

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 "";
}
Also used : StringTokenizer(com.ibm.icu.util.StringTokenizer)

Example 48 with StringTokenizer

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;
}
Also used : StringTokenizer(com.ibm.icu.util.StringTokenizer)

Example 49 with StringTokenizer

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);
    }
}
Also used : StringTokenizer(com.ibm.icu.util.StringTokenizer)

Example 50 with StringTokenizer

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;
}
Also used : StringTokenizer(com.ibm.icu.util.StringTokenizer)

Aggregations

StringTokenizer (com.ibm.icu.util.StringTokenizer)53 ArrayList (java.util.ArrayList)9 List (java.util.List)6 HashSet (java.util.HashSet)4 IDOMAttr (org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr)4 Attr (org.w3c.dom.Attr)4 Set (java.util.Set)3 Point (org.eclipse.swt.graphics.Point)3 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)3 InputStream (java.io.InputStream)2 Iterator (java.util.Iterator)2 Pattern (java.util.regex.Pattern)2 IFile (org.eclipse.core.resources.IFile)2 IProject (org.eclipse.core.resources.IProject)2 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)2 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)2 IDocument (org.eclipse.jface.text.IDocument)2