use of com.ibm.icu.util.StringTokenizer in project webtools.sourceediting by eclipse.
the class HTMLFormattingUtil method getInlineSet.
private static Set getInlineSet() {
String inline = HTMLCorePlugin.getDefault().getPluginPreferences().getString(HTMLCorePreferenceNames.INLINE_ELEMENTS);
Set elements = new HashSet();
StringTokenizer tokenizer = new StringTokenizer(inline, ",");
while (tokenizer.hasMoreTokens()) {
elements.add(tokenizer.nextToken());
}
return elements;
}
use of com.ibm.icu.util.StringTokenizer in project webtools.sourceediting by eclipse.
the class HTMLFormattingUtil method getDefaultInlineElements.
/**
* Returns an array of the default element names considered as "inline" for the purposes of formatting.
*
* @return An array of the default element names considered to be "inline"
*/
public static Object[] getDefaultInlineElements() {
String inline = HTMLCorePlugin.getDefault().getPluginPreferences().getDefaultString(HTMLCorePreferenceNames.INLINE_ELEMENTS);
Set defaults = new HashSet();
StringTokenizer tokenizer = new StringTokenizer(inline, ",");
while (tokenizer.hasMoreTokens()) {
defaults.add(tokenizer.nextToken());
}
return defaults.toArray();
}
use of com.ibm.icu.util.StringTokenizer in project webtools.sourceediting by eclipse.
the class HTMLStyleSelectorAdapter method match.
public boolean match(ICSSSimpleSelector selector, Element element, String pseudoName) {
if (element == null)
return false;
int i;
String key;
// PseudoName
i = selector.getNumOfPseudoNames();
if (i > 0) {
if (pseudoName == null || pseudoName.length() == 0)
return false;
for (i = i - 1; i >= 0; i--) {
if (pseudoName.equalsIgnoreCase(selector.getPseudoName(i))) {
break;
}
}
if (i < 0)
return false;
}
// check tag name
if (!selector.isUniversal() && !element.getNodeName().equalsIgnoreCase(selector.getName()))
return false;
// check id
i = selector.getNumOfIDs();
if (i > 0) {
if (i > 1)
return false;
if (// $NON-NLS-1$ //$NON-NLS-2$
!element.hasAttribute("id") || (key = element.getAttribute("id")).length() == 0)
return false;
if (!selector.getID(0).equals(key))
return false;
}
// check class
i = selector.getNumOfClasses();
if (i > 0) {
if (// $NON-NLS-1$ //$NON-NLS-2$
!element.hasAttribute("class") || (key = element.getAttribute("class")).length() == 0)
return false;
StringTokenizer tokenizer = new StringTokenizer(key);
for (i = i - 1; i >= 0; i--) {
boolean ok = false;
while (tokenizer.hasMoreTokens()) {
if (selector.getClass(i).equals(tokenizer.nextToken())) {
ok = true;
break;
}
}
if (!ok)
return false;
}
}
// check attributes
for (i = selector.getNumOfAttributes() - 1; i >= 0; i--) {
// $NON-NLS-1$
StringTokenizer tokenizer = new StringTokenizer(selector.getAttribute(i), "=~| \t\r\n\f");
int countTokens = tokenizer.countTokens();
if (countTokens > 0) {
String attrName = tokenizer.nextToken();
String attrValue = null;
if (!element.hasAttribute(attrName) || (attrValue = element.getAttribute(attrName)).length() == 0)
return false;
if (countTokens > 1) {
// $NON-NLS-1$
String token = tokenizer.nextToken("= \t\r\n\f");
StringTokenizer attrValueTokenizer = null;
if (token.equals("~")) {
// $NON-NLS-1$
attrValueTokenizer = new StringTokenizer(attrValue);
} else if (token.equals("|")) {
// $NON-NLS-1$
// $NON-NLS-1$
attrValueTokenizer = new StringTokenizer(attrValue, "-");
}
if (attrValueTokenizer != null) {
if (tokenizer.hasMoreTokens()) {
token = tokenizer.nextToken();
boolean ok = false;
while (attrValueTokenizer.hasMoreTokens()) {
if (token.equals(attrValueTokenizer.nextToken())) {
ok = true;
break;
}
}
if (!ok)
return false;
}
} else {
if (!attrValue.equals(token))
return false;
}
}
}
}
return true;
}
Aggregations