use of org.apache.xml.utils.FastStringBuffer in project j2objc by google.
the class XStringForFSB method startsWith.
/**
* Tests if this string starts with the specified prefix beginning
* a specified index.
*
* @param prefix the prefix.
* @param toffset where to begin looking in the string.
* @return <code>true</code> if the character sequence represented by the
* argument is a prefix of the substring of this object starting
* at index <code>toffset</code>; <code>false</code> otherwise.
* The result is <code>false</code> if <code>toffset</code> is
* negative or greater than the length of this
* <code>String</code> object; otherwise the result is the same
* as the result of the expression
* <pre>
* this.subString(toffset).startsWith(prefix)
* </pre>
* @exception java.lang.NullPointerException if <code>prefix</code> is
* <code>null</code>.
*/
public boolean startsWith(XMLString prefix, int toffset) {
FastStringBuffer fsb = fsb();
int to = m_start + toffset;
int tlim = m_start + m_length;
int po = 0;
int pc = prefix.length();
// Note: toffset might be near -1>>>1.
if ((toffset < 0) || (toffset > m_length - pc)) {
return false;
}
while (--pc >= 0) {
if (fsb.charAt(to) != prefix.charAt(po)) {
return false;
}
to++;
po++;
}
return true;
}
use of org.apache.xml.utils.FastStringBuffer in project j2objc by google.
the class XStringForFSB method equals.
/**
* Compares this string to the specified object.
* The result is <code>true</code> if and only if the argument is not
* <code>null</code> and is a <code>String</code> object that represents
* the same sequence of characters as this object.
*
* @param obj2 the object to compare this <code>String</code>
* against.
*
* @return <code>true</code> if the <code>String </code>are equal;
* <code>false</code> otherwise.
* @see java.lang.String#compareTo(java.lang.String)
* @see java.lang.String#equalsIgnoreCase(java.lang.String)
*/
public boolean equals(XMLString obj2) {
if (this == obj2) {
return true;
}
int n = m_length;
if (n == obj2.length()) {
FastStringBuffer fsb = fsb();
int i = m_start;
int j = 0;
while (n-- != 0) {
if (fsb.charAt(i) != obj2.charAt(j)) {
return false;
}
i++;
j++;
}
return true;
}
return false;
}
use of org.apache.xml.utils.FastStringBuffer in project j2objc by google.
the class ElemNumber method getFormattedNumber.
// end formatNumberList method
/*
* Get Formatted number
*/
/**
* Format the given number and store it in the given buffer
*
*
* @param transformer non-null reference to the the current transform-time state.
* @param contextNode The node that "." expresses.
* @param numberType Type to format to
* @param numberWidth Maximum length of formatted number
* @param listElement Number to format
* @param formattedNumber Buffer to store formatted number
*
* @throws javax.xml.transform.TransformerException
*/
private void getFormattedNumber(TransformerImpl transformer, int contextNode, char numberType, int numberWidth, long listElement, FastStringBuffer formattedNumber) throws javax.xml.transform.TransformerException {
String letterVal = (m_lettervalue_avt != null) ? m_lettervalue_avt.evaluate(transformer.getXPathContext(), contextNode, this) : null;
/**
* Wrapper of Chars for converting integers into alpha counts.
*/
CharArrayWrapper alphaCountTable = null;
XResourceBundle thisBundle = null;
switch(numberType) {
case 'A':
if (null == m_alphaCountTable) {
thisBundle = (XResourceBundle) XResourceBundle.loadResourceBundle(org.apache.xml.utils.res.XResourceBundle.LANG_BUNDLE_NAME, getLocale(transformer, contextNode));
m_alphaCountTable = (CharArrayWrapper) thisBundle.getObject(org.apache.xml.utils.res.XResourceBundle.LANG_ALPHABET);
}
int2alphaCount(listElement, m_alphaCountTable, formattedNumber);
break;
case 'a':
if (null == m_alphaCountTable) {
thisBundle = (XResourceBundle) XResourceBundle.loadResourceBundle(org.apache.xml.utils.res.XResourceBundle.LANG_BUNDLE_NAME, getLocale(transformer, contextNode));
m_alphaCountTable = (CharArrayWrapper) thisBundle.getObject(org.apache.xml.utils.res.XResourceBundle.LANG_ALPHABET);
}
FastStringBuffer stringBuf = StringBufferPool.get();
try {
int2alphaCount(listElement, m_alphaCountTable, stringBuf);
formattedNumber.append(stringBuf.toString().toLowerCase(getLocale(transformer, contextNode)));
} finally {
StringBufferPool.free(stringBuf);
}
break;
case 'I':
formattedNumber.append(long2roman(listElement, true));
break;
case 'i':
formattedNumber.append(long2roman(listElement, true).toLowerCase(getLocale(transformer, contextNode)));
break;
case 0x3042:
{
thisBundle = (XResourceBundle) XResourceBundle.loadResourceBundle(org.apache.xml.utils.res.XResourceBundle.LANG_BUNDLE_NAME, new Locale("ja", "JP", "HA"));
if (letterVal != null && letterVal.equals(Constants.ATTRVAL_TRADITIONAL))
formattedNumber.append(tradAlphaCount(listElement, thisBundle));
else
//if (m_lettervalue_avt != null && m_lettervalue_avt.equals(Constants.ATTRVAL_ALPHABETIC))
formattedNumber.append(int2singlealphaCount(listElement, (CharArrayWrapper) thisBundle.getObject(org.apache.xml.utils.res.XResourceBundle.LANG_ALPHABET)));
break;
}
case 0x3044:
{
thisBundle = (XResourceBundle) XResourceBundle.loadResourceBundle(org.apache.xml.utils.res.XResourceBundle.LANG_BUNDLE_NAME, new Locale("ja", "JP", "HI"));
if ((letterVal != null) && letterVal.equals(Constants.ATTRVAL_TRADITIONAL))
formattedNumber.append(tradAlphaCount(listElement, thisBundle));
else
//if (m_lettervalue_avt != null && m_lettervalue_avt.equals(Constants.ATTRVAL_ALPHABETIC))
formattedNumber.append(int2singlealphaCount(listElement, (CharArrayWrapper) thisBundle.getObject(org.apache.xml.utils.res.XResourceBundle.LANG_ALPHABET)));
break;
}
case 0x30A2:
{
thisBundle = (XResourceBundle) XResourceBundle.loadResourceBundle(org.apache.xml.utils.res.XResourceBundle.LANG_BUNDLE_NAME, new Locale("ja", "JP", "A"));
if (letterVal != null && letterVal.equals(Constants.ATTRVAL_TRADITIONAL))
formattedNumber.append(tradAlphaCount(listElement, thisBundle));
else
//if (m_lettervalue_avt != null && m_lettervalue_avt.equals(Constants.ATTRVAL_ALPHABETIC))
formattedNumber.append(int2singlealphaCount(listElement, (CharArrayWrapper) thisBundle.getObject(org.apache.xml.utils.res.XResourceBundle.LANG_ALPHABET)));
break;
}
case 0x30A4:
{
thisBundle = (XResourceBundle) XResourceBundle.loadResourceBundle(org.apache.xml.utils.res.XResourceBundle.LANG_BUNDLE_NAME, new Locale("ja", "JP", "I"));
if (letterVal != null && letterVal.equals(Constants.ATTRVAL_TRADITIONAL))
formattedNumber.append(tradAlphaCount(listElement, thisBundle));
else
//if (m_lettervalue_avt != null && m_lettervalue_avt.equals(Constants.ATTRVAL_ALPHABETIC))
formattedNumber.append(int2singlealphaCount(listElement, (CharArrayWrapper) thisBundle.getObject(org.apache.xml.utils.res.XResourceBundle.LANG_ALPHABET)));
break;
}
case 0x4E00:
{
thisBundle = (XResourceBundle) XResourceBundle.loadResourceBundle(org.apache.xml.utils.res.XResourceBundle.LANG_BUNDLE_NAME, new Locale("zh", "CN"));
if (letterVal != null && letterVal.equals(Constants.ATTRVAL_TRADITIONAL)) {
formattedNumber.append(tradAlphaCount(listElement, thisBundle));
} else
//if (m_lettervalue_avt != null && m_lettervalue_avt.equals(Constants.ATTRVAL_ALPHABETIC))
int2alphaCount(listElement, (CharArrayWrapper) thisBundle.getObject(org.apache.xml.utils.res.XResourceBundle.LANG_ALPHABET), formattedNumber);
break;
}
case 0x58F9:
{
thisBundle = (XResourceBundle) XResourceBundle.loadResourceBundle(org.apache.xml.utils.res.XResourceBundle.LANG_BUNDLE_NAME, new Locale("zh", "TW"));
if (letterVal != null && letterVal.equals(Constants.ATTRVAL_TRADITIONAL))
formattedNumber.append(tradAlphaCount(listElement, thisBundle));
else
//if (m_lettervalue_avt != null && m_lettervalue_avt.equals(Constants.ATTRVAL_ALPHABETIC))
int2alphaCount(listElement, (CharArrayWrapper) thisBundle.getObject(org.apache.xml.utils.res.XResourceBundle.LANG_ALPHABET), formattedNumber);
break;
}
case 0x0E51:
{
thisBundle = (XResourceBundle) XResourceBundle.loadResourceBundle(org.apache.xml.utils.res.XResourceBundle.LANG_BUNDLE_NAME, new Locale("th", ""));
if (letterVal != null && letterVal.equals(Constants.ATTRVAL_TRADITIONAL))
formattedNumber.append(tradAlphaCount(listElement, thisBundle));
else
//if (m_lettervalue_avt != null && m_lettervalue_avt.equals(Constants.ATTRVAL_ALPHABETIC))
int2alphaCount(listElement, (CharArrayWrapper) thisBundle.getObject(org.apache.xml.utils.res.XResourceBundle.LANG_ALPHABET), formattedNumber);
break;
}
case 0x05D0:
{
thisBundle = (XResourceBundle) XResourceBundle.loadResourceBundle(org.apache.xml.utils.res.XResourceBundle.LANG_BUNDLE_NAME, new Locale("he", ""));
if (letterVal != null && letterVal.equals(Constants.ATTRVAL_TRADITIONAL))
formattedNumber.append(tradAlphaCount(listElement, thisBundle));
else
//if (m_lettervalue_avt != null && m_lettervalue_avt.equals(Constants.ATTRVAL_ALPHABETIC))
int2alphaCount(listElement, (CharArrayWrapper) thisBundle.getObject(org.apache.xml.utils.res.XResourceBundle.LANG_ALPHABET), formattedNumber);
break;
}
case 0x10D0:
{
thisBundle = (XResourceBundle) XResourceBundle.loadResourceBundle(org.apache.xml.utils.res.XResourceBundle.LANG_BUNDLE_NAME, new Locale("ka", ""));
if (letterVal != null && letterVal.equals(Constants.ATTRVAL_TRADITIONAL))
formattedNumber.append(tradAlphaCount(listElement, thisBundle));
else
//if (m_lettervalue_avt != null && m_lettervalue_avt.equals(Constants.ATTRVAL_ALPHABETIC))
int2alphaCount(listElement, (CharArrayWrapper) thisBundle.getObject(org.apache.xml.utils.res.XResourceBundle.LANG_ALPHABET), formattedNumber);
break;
}
case 0x03B1:
{
thisBundle = (XResourceBundle) XResourceBundle.loadResourceBundle(org.apache.xml.utils.res.XResourceBundle.LANG_BUNDLE_NAME, new Locale("el", ""));
if (letterVal != null && letterVal.equals(Constants.ATTRVAL_TRADITIONAL))
formattedNumber.append(tradAlphaCount(listElement, thisBundle));
else
//if (m_lettervalue_avt != null && m_lettervalue_avt.equals(Constants.ATTRVAL_ALPHABETIC))
int2alphaCount(listElement, (CharArrayWrapper) thisBundle.getObject(org.apache.xml.utils.res.XResourceBundle.LANG_ALPHABET), formattedNumber);
break;
}
case 0x0430:
{
thisBundle = (XResourceBundle) XResourceBundle.loadResourceBundle(org.apache.xml.utils.res.XResourceBundle.LANG_BUNDLE_NAME, new Locale("cy", ""));
if (letterVal != null && letterVal.equals(Constants.ATTRVAL_TRADITIONAL))
formattedNumber.append(tradAlphaCount(listElement, thisBundle));
else
//if (m_lettervalue_avt != null && m_lettervalue_avt.equals(Constants.ATTRVAL_ALPHABETIC))
int2alphaCount(listElement, (CharArrayWrapper) thisBundle.getObject(org.apache.xml.utils.res.XResourceBundle.LANG_ALPHABET), formattedNumber);
break;
}
default:
// "1"
DecimalFormat formatter = getNumberFormatter(transformer, contextNode);
String padString = formatter == null ? String.valueOf(0) : formatter.format(0);
String numString = formatter == null ? String.valueOf(listElement) : formatter.format(listElement);
int nPadding = numberWidth - numString.length();
for (int k = 0; k < nPadding; k++) {
formattedNumber.append(padString);
}
formattedNumber.append(numString);
}
}
use of org.apache.xml.utils.FastStringBuffer in project j2objc by google.
the class DOM2DTM method isWhitespace.
/**
* Determine if the string-value of a node is whitespace
*
* @param nodeHandle The node Handle.
*
* @return Return true if the given node is whitespace.
*/
public boolean isWhitespace(int nodeHandle) {
int type = getNodeType(nodeHandle);
Node node = getNode(nodeHandle);
if (TEXT_NODE == type || CDATA_SECTION_NODE == type) {
// If this is a DTM text node, it may be made of multiple DOM text
// nodes -- including navigating into Entity References. DOM2DTM
// records the first node in the sequence and requires that we
// pick up the others when we retrieve the DTM node's value.
//
// %REVIEW% DOM Level 3 is expected to add a "whole text"
// retrieval method which performs this function for us.
FastStringBuffer buf = StringBufferPool.get();
while (node != null) {
buf.append(node.getNodeValue());
node = logicalNextDOMTextNode(node);
}
boolean b = buf.isWhitespace(0, buf.length());
StringBufferPool.free(buf);
return b;
}
return false;
}
use of org.apache.xml.utils.FastStringBuffer in project robovm by robovm.
the class OutputProperties method setQNameProperties.
/**
* Set an output property with a QName list value. The QNames will be turned
* into strings with the namespace in curly brackets.
*
* @param key the key to be placed into the property list.
* @param v non-null list of QNames corresponding to <tt>key</tt>.
* @see javax.xml.transform.OutputKeys
*/
public void setQNameProperties(String key, Vector v) {
int s = v.size();
// Just an initial guess at reasonable tuning parameters
FastStringBuffer fsb = new FastStringBuffer(9, 9);
for (int i = 0; i < s; i++) {
QName qname = (QName) v.elementAt(i);
fsb.append(qname.toNamespacedString());
// Don't append space after last value
if (i < s - 1)
fsb.append(' ');
}
m_properties.put(key, fsb.toString());
}
Aggregations