use of com.ibm.icu.util.StringTokenizer in project mycore by MyCoRe-Org.
the class MCRDefaultConfigurationLoader method loadFromContent.
private void loadFromContent(MCRContent input) throws IOException {
try (InputStream in = input.getInputStream()) {
properties.load(in);
}
String include = properties.getProperty("MCR.Configuration.Include", null);
if (include != null) {
StringTokenizer st = new StringTokenizer(include, ", ");
properties.remove("MCR.Configuration.Include");
while (st.hasMoreTokens()) {
loadFromFile(st.nextToken());
}
}
}
use of com.ibm.icu.util.StringTokenizer in project webtools.sourceediting by eclipse.
the class XMLHyperlinkDetector method getURIString.
/**
* Returns the URI string
*
* @param node -
* assumes not null
*/
private String getURIString(Node node, IDocument document, IRegion region) {
String resolvedURI = null;
// need the base location, publicId, and systemId for URIResolver
String baseLoc = null;
String publicId = null;
String systemId = null;
short nodeType = node.getNodeType();
// handle doc type node
if (nodeType == Node.DOCUMENT_TYPE_NODE) {
baseLoc = getBaseLocation(document);
publicId = ((DocumentType) node).getPublicId();
systemId = ((DocumentType) node).getSystemId();
} else if (nodeType == Node.ATTRIBUTE_NODE) {
// handle attribute node
Attr attrNode = (Attr) node;
String attrName = attrNode.getName();
String attrValue = attrNode.getValue();
attrValue = StringUtils.strip(attrValue);
if ((attrValue != null) && (attrValue.length() > 0)) {
baseLoc = getBaseLocation(document);
// handle schemaLocation attribute
String prefix = DOMNamespaceHelper.getPrefix(attrName);
String unprefixedName = DOMNamespaceHelper.getUnprefixedName(attrName);
if ((XMLNS.equals(prefix)) || (XMLNS.equals(unprefixedName))) {
publicId = attrValue;
systemId = getLocationHint(attrNode.getOwnerElement(), publicId);
if (systemId == null) {
systemId = attrValue;
}
} else if ((XSI_NAMESPACE_URI.equals(DOMNamespaceHelper.getNamespaceURI(attrNode))) && (SCHEMA_LOCATION.equals(unprefixedName))) {
// for now just use the first pair
// need to look into being more precise
// Being precise now
// $NON-NLS-1$
String attrText = "";
int relativeOffset = -1;
if (node instanceof IDOMNode) {
relativeOffset = region.getOffset() - ((IDOMNode) node).getStartOffset();
try {
attrText = document.get(((IDOMNode) node).getStartOffset(), ((IDOMNode) node).getLength());
} catch (BadLocationException e) {
Logger.logException(e);
}
}
StringTokenizer st = new StringTokenizer(attrValue);
while (st.hasMoreTokens()) {
publicId = st.nextToken();
systemId = st.hasMoreTokens() ? st.nextToken() : null;
int startOffset = -1;
int endOffset = -1;
if (publicId != null) {
startOffset = attrText.indexOf(publicId);
if (systemId != null) {
endOffset = attrText.indexOf(systemId) + systemId.length();
} else {
endOffset = attrText.indexOf(publicId) + publicId.length();
}
}
if (startOffset <= relativeOffset && relativeOffset <= endOffset)
break;
// else check if xmlns publicId = value
}
} else {
systemId = attrValue;
}
}
}
resolvedURI = resolveURI(baseLoc, publicId, systemId);
return resolvedURI;
}
use of com.ibm.icu.util.StringTokenizer in project webtools.sourceediting by eclipse.
the class XMLHyperlinkDetector method getLocationHint.
/**
* Find the location hint for the given namespaceURI if it exists
*
* @param elementNode -
* cannot be null
* @param namespaceURI -
* cannot be null
* @return location hint (systemId) if it was found, null otherwise
*/
private String getLocationHint(Element elementNode, String namespaceURI) {
Attr schemaLocNode = elementNode.getAttributeNodeNS(XSI_NAMESPACE_URI, SCHEMA_LOCATION);
if (schemaLocNode != null) {
StringTokenizer st = new StringTokenizer(schemaLocNode.getValue());
while (st.hasMoreTokens()) {
String publicId = st.hasMoreTokens() ? st.nextToken() : null;
String systemId = st.hasMoreTokens() ? st.nextToken() : null;
// found location hint
if (namespaceURI.equalsIgnoreCase(publicId)) {
return systemId;
}
}
}
return null;
}
use of com.ibm.icu.util.StringTokenizer in project webtools.sourceediting by eclipse.
the class ActionDescriptor method convertAccelerator.
/**
* Parses the given accelerator text, and converts it to an accelerator
* key code.
*
* @param acceleratorText
* the accelerator text
* @result the SWT key code, or 0 if there is no accelerator
*/
private int convertAccelerator(String acceleratorText) {
int accelerator = 0;
// $NON-NLS-1$
StringTokenizer stok = new StringTokenizer(acceleratorText, "+");
int keyCode = -1;
boolean hasMoreTokens = stok.hasMoreTokens();
while (hasMoreTokens) {
String token = stok.nextToken();
hasMoreTokens = stok.hasMoreTokens();
// Ctrl, Shift, or Alt.
if (hasMoreTokens) {
int modifier = Action.findModifier(token);
if (modifier != 0) {
accelerator |= modifier;
} else {
// Leave if there are none
return 0;
}
} else {
keyCode = Action.findKeyCode(token);
}
}
if (keyCode != -1) {
accelerator |= keyCode;
}
return accelerator;
}
use of com.ibm.icu.util.StringTokenizer in project webtools.sourceediting by eclipse.
the class AbstractCompletionProposalCategoriesConfiguration method loadPageSortOrder.
/**
* <p>Loads the user preferences for the sort order of the content assist pages</p>
*
* @param useDefaults if <code>true</code> then use the {@link IPreferenceStore} defaults,
* otherwise use the user specified preferences
*/
private void loadPageSortOrder(boolean useDefaults) {
// clear the current sort order
this.fOwnPageSortOrder.clear();
// parse either the default or user configuration preference
String sortOrder;
if (useDefaults) {
sortOrder = getPreferenceStore().getDefaultString(getPageSortOrderPrefKey());
} else {
sortOrder = getPreferenceStore().getString(getPageSortOrderPrefKey());
}
StringTokenizer tokenizer = new StringTokenizer(sortOrder, PREFERENCE_CATEGORY_SEPERATOR);
while (tokenizer.hasMoreTokens()) {
String categoryID = tokenizer.nextToken();
this.fOwnPageSortOrder.add(categoryID);
}
}
Aggregations