當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。