当前位置: 首页>>代码示例>>Java>>正文


Java Cursor类代码示例

本文整理汇总了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();
}
 
开发者ID:codewise,项目名称:RxS3,代码行数:26,代码来源:DateTimeParser.java

示例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();
}
 
开发者ID:codewise,项目名称:RxS3,代码行数:8,代码来源:DateTimeParser.java

示例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);
}
 
开发者ID:codewise,项目名称:RxS3,代码行数:16,代码来源:DateTimeParserTest.java

示例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);
}
 
开发者ID:codewise,项目名称:RxS3,代码行数:16,代码来源:DateTimeParserTest.java

示例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());
}
 
开发者ID:codewise,项目名称:RxS3,代码行数:13,代码来源:DateTimeParserTest.java

示例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());
}
 
开发者ID:codewise,项目名称:RxS3,代码行数:13,代码来源:DateTimeParserTest.java

示例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());
}
 
开发者ID:codewise,项目名称:RxS3,代码行数:13,代码来源:DateTimeParserTest.java

示例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;
}
 
开发者ID:kno10,项目名称:libModernSVM,代码行数:28,代码来源:LibSVMDataReader.java

示例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");
    }
}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:11,代码来源:TextContextImpl.java

示例10: getCursor

import javolution.text.Cursor; //导入依赖的package包/类
public Cursor getCursor() {
    cursor.setIndex(0);
    return cursor;
}
 
开发者ID:codewise,项目名称:RxS3,代码行数:5,代码来源:ContextStack.java

示例11: parse

import javolution.text.Cursor; //导入依赖的package包/类
@Override
public FastCollection<Object> parse(CharSequence csq, Cursor cursor)
        throws IllegalArgumentException {
    throw new UnsupportedOperationException();
}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:6,代码来源:FastCollection.java

示例12: parse

import javolution.text.Cursor; //导入依赖的package包/类
@Override
public Index parse(CharSequence csq, Cursor cursor)
		throws IllegalArgumentException {
	return Index.of(TypeFormat.parseInt(csq, cursor));
}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:6,代码来源:Index.java

示例13: parse

import javolution.text.Cursor; //导入依赖的package包/类
@Override
public FastMap<Object, Object> parse(CharSequence csq, Cursor cursor)
        throws IllegalArgumentException {
    throw new UnsupportedOperationException();
}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:6,代码来源:FastMap.java


注:本文中的javolution.text.Cursor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。