本文整理汇总了Java中javolution.text.CharArray.setArray方法的典型用法代码示例。如果您正苦于以下问题:Java CharArray.setArray方法的具体用法?Java CharArray.setArray怎么用?Java CharArray.setArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javolution.text.CharArray
的用法示例。
在下文中一共展示了CharArray.setArray方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldParseDate
import javolution.text.CharArray; //导入方法依赖的package包/类
@Test
public void shouldParseDate() {
// Given
DateTimeParser parser = new DateTimeParser();
String expected = "2014-12-20T23:02:11.000Z";
CharArray charArray = new CharArray();
charArray.setArray(expected.toCharArray(), 0, expected.length());
// When
Date actual = parser.parse(charArray, new Cursor(), Calendar.getInstance());
// Then
assertThat(actual).isEqualTo(expected);
}
示例2: shouldParseDateWithMillis
import javolution.text.CharArray; //导入方法依赖的package包/类
@Test
public void shouldParseDateWithMillis() {
// Given
DateTimeParser parser = new DateTimeParser();
String expected = "2014-12-20T23:02:11.123Z";
CharArray charArray = new CharArray();
charArray.setArray(expected.toCharArray(), 0, expected.length());
// When
Date actual = parser.parse(charArray, new Cursor(), Calendar.getInstance());
// Then
assertThat(actual).isEqualTo(expected);
}
示例3: shouldComplainOnInvalidYear
import javolution.text.CharArray; //导入方法依赖的package包/类
@Test(expectedExceptions = IllegalArgumentException.class)
public void shouldComplainOnInvalidYear() {
// Given
DateTimeParser parser = new DateTimeParser();
String expected = "120a-12-20T23:02:11.123Z";
CharArray charArray = new CharArray();
charArray.setArray(expected.toCharArray(), 0, expected.length());
// When
parser.parse(charArray, new Cursor(), Calendar.getInstance());
}
示例4: shouldComplainOnInvalidYearMonthSeparator
import javolution.text.CharArray; //导入方法依赖的package包/类
@Test(expectedExceptions = IllegalArgumentException.class)
public void shouldComplainOnInvalidYearMonthSeparator() {
// Given
DateTimeParser parser = new DateTimeParser();
String expected = "2120+12-20T23:02:11.123Z";
CharArray charArray = new CharArray();
charArray.setArray(expected.toCharArray(), 0, expected.length());
// When
parser.parse(charArray, new Cursor(), Calendar.getInstance());
}
示例5: shouldComplainOnInvalidMonthDaysSeparator
import javolution.text.CharArray; //导入方法依赖的package包/类
@Test(expectedExceptions = IllegalArgumentException.class)
public void shouldComplainOnInvalidMonthDaysSeparator() {
// Given
DateTimeParser parser = new DateTimeParser();
String expected = "2120-12+20T23:02:11.123Z";
CharArray charArray = new CharArray();
charArray.setArray(expected.toCharArray(), 0, expected.length());
// When
parser.parse(charArray, new Cursor(), Calendar.getInstance());
}
示例6: getElementText
import javolution.text.CharArray; //导入方法依赖的package包/类
public CharArray getElementText() throws XMLStreamException {
// Derived from interface specification code.
if (getEventType() != XMLStreamConstants.START_ELEMENT) { throw new XMLStreamException(
"Parser must be on START_ELEMENT to read next text",
getLocation()); }
CharArray text = null;
int eventType = next();
while (eventType != XMLStreamConstants.END_ELEMENT) {
if (eventType == XMLStreamConstants.CHARACTERS) {
if (text == null) {
text = getText();
} else { // Merge (adjacent text, comments and PI are not kept).
text.setArray(_data, text.offset(), text.length()
+ getText().length());
}
} else if (eventType == XMLStreamConstants.PROCESSING_INSTRUCTION
|| eventType == XMLStreamConstants.COMMENT) {
// Skips (not kept).
} else if (eventType == XMLStreamConstants.END_DOCUMENT) {
throw new XMLStreamException(
"Unexpected end of document when reading element text content",
getLocation());
} else if (eventType == XMLStreamConstants.START_ELEMENT) {
throw new XMLStreamException(
"Element text content may not contain START_ELEMENT",
getLocation());
} else {
throw new XMLStreamException("Unexpected event type "
+ NAMES_OF_EVENTS[eventType], getLocation());
}
eventType = next();
}
return (text != null) ? text : newSeq(0, 0);
}
示例7: setPrefix
import javolution.text.CharArray; //导入方法依赖的package包/类
void setPrefix(final CharSequence prefix, CharSequence uri,
boolean isWritten) {
final int index = _namespacesCount[_nesting];
_prefixesWritten[index] = isWritten;
final int prefixLength = prefix.length();
CharArray prefixTmp = _prefixesTmp[index];
if ((prefixTmp == null) || (prefixTmp.array().length < prefixLength)) {
_prefixesTmp[index] = new CharArray().setArray(
new char[prefixLength + 32], 0, 0);
prefixTmp = _prefixesTmp[index];
}
for (int i = 0; i < prefixLength; i++) {
prefixTmp.array()[i] = prefix.charAt(i);
}
prefixTmp.setArray(prefixTmp.array(), 0, prefixLength);
final int uriLength = uri.length();
CharArray namespaceTmp = _namespacesTmp[index];
if ((namespaceTmp == null) || (namespaceTmp.array().length < uriLength)) {
_namespacesTmp[index] = new CharArray().setArray(
new char[uriLength + 32], 0, 0);
namespaceTmp = _namespacesTmp[index];
}
for (int i = 0; i < uriLength; i++) {
namespaceTmp.array()[i] = uri.charAt(i);
}
namespaceTmp.setArray(namespaceTmp.array(), 0, uriLength);
// Sets the prefix using CharArray instances.
setPrefix(prefixTmp, namespaceTmp);
}
示例8: newSeq
import javolution.text.CharArray; //导入方法依赖的package包/类
private CharArray newSeq(int offset, int length) {
CharArray seq = (_seqsIndex < _seqsCapacity) ? _seqs[_seqsIndex++]
: newSeq2();
return seq.setArray(_data, offset, length);
}