本文整理汇总了Java中javolution.text.Cursor类的典型用法代码示例。如果您正苦于以下问题:Java Cursor类的具体用法?Java Cursor怎么用?Java Cursor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Cursor类属于javolution.text包,在下文中一共展示了Cursor类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import javolution.text.Cursor; //导入依赖的package包/类
public Date parse(CharArray text, Cursor cursor, Calendar calendar) {
cursor.setIndex(0);
calendar.set(Calendar.YEAR, TypeFormat.parseInt(text, cursor));
verifyCharacterAndAdvanceCursor(text, cursor, '-');
calendar.set(Calendar.MONTH, TypeFormat.parseInt(text, cursor) - 1);
verifyCharacterAndAdvanceCursor(text, cursor, '-');
calendar.set(Calendar.DAY_OF_MONTH, TypeFormat.parseInt(text, cursor));
verifyCharacterAndAdvanceCursor(text, cursor, 'T');
calendar.set(Calendar.HOUR_OF_DAY, TypeFormat.parseInt(text, cursor));
verifyCharacterAndAdvanceCursor(text, cursor, ':');
calendar.set(Calendar.MINUTE, TypeFormat.parseInt(text, cursor));
verifyCharacterAndAdvanceCursor(text, cursor, ':');
calendar.set(Calendar.SECOND, TypeFormat.parseInt(text, cursor));
verifyCharacterAndAdvanceCursor(text, cursor, '.');
calendar.set(Calendar.MILLISECOND, TypeFormat.parseInt(text, cursor));
verifyCharacterAndAdvanceCursor(text, cursor, 'Z');
return calendar.getTime();
}
示例2: verifyCharacterAndAdvanceCursor
import javolution.text.Cursor; //导入依赖的package包/类
private void verifyCharacterAndAdvanceCursor(CharArray text, Cursor cursor, char expectedCharacter) {
if (text.charAt(cursor.getIndex()) != expectedCharacter) {
throw new IllegalArgumentException(text.toString());
}
cursor.increment();
}
示例3: shouldParseDate
import javolution.text.Cursor; //导入依赖的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);
}
示例4: shouldParseDateWithMillis
import javolution.text.Cursor; //导入依赖的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);
}
示例5: shouldComplainOnInvalidYear
import javolution.text.Cursor; //导入依赖的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());
}
示例6: shouldComplainOnInvalidYearMonthSeparator
import javolution.text.Cursor; //导入依赖的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());
}
示例7: shouldComplainOnInvalidMonthDaysSeparator
import javolution.text.Cursor; //导入依赖的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());
}
示例8: loadData
import javolution.text.Cursor; //导入依赖的package包/类
public static <V extends Vector<?>> DataSet<V> loadData(FileInputStream in, VectorBuilder<? extends V> builder) throws IOException {
ByteWeightedArrayDataSet<V> data = new ByteWeightedArrayDataSet<V>(1000);
BufferedReader r = null;
try {
r = new BufferedReader(new InputStreamReader(in));
String line;
Cursor cursor = new Cursor();
while((line = r.readLine()) != null) {
cursor.setIndex(0);
byte c = TypeFormat.parseByte(line, cursor);
builder.clear();
while(cursor.skip(' ', line) && cursor.getIndex() < line.length()) {
int idx = TypeFormat.parseInt(line, cursor) - 1;
cursor.skip(':', line);
double val = TypeFormat.parseDouble(line, cursor);
builder.add(idx, val);
}
data.add(builder.build(), c);
}
}
finally {
if(r != null) {
r.close();
}
}
return data;
}
示例9: parse
import javolution.text.Cursor; //导入依赖的package包/类
@Override
public Class<?> parse(CharSequence csq, Cursor cursor) {
CharSequence name = cursor.nextToken(csq, CharSet.WHITESPACES);
try {
return Class.forName(name.toString());
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("Class " + name
+ " Not Found");
}
}
示例10: getCursor
import javolution.text.Cursor; //导入依赖的package包/类
public Cursor getCursor() {
cursor.setIndex(0);
return cursor;
}
示例11: parse
import javolution.text.Cursor; //导入依赖的package包/类
@Override
public FastCollection<Object> parse(CharSequence csq, Cursor cursor)
throws IllegalArgumentException {
throw new UnsupportedOperationException();
}
示例12: parse
import javolution.text.Cursor; //导入依赖的package包/类
@Override
public Index parse(CharSequence csq, Cursor cursor)
throws IllegalArgumentException {
return Index.of(TypeFormat.parseInt(csq, cursor));
}
示例13: parse
import javolution.text.Cursor; //导入依赖的package包/类
@Override
public FastMap<Object, Object> parse(CharSequence csq, Cursor cursor)
throws IllegalArgumentException {
throw new UnsupportedOperationException();
}