本文整理汇总了Java中java.util.AbstractList类的典型用法代码示例。如果您正苦于以下问题:Java AbstractList类的具体用法?Java AbstractList怎么用?Java AbstractList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbstractList类属于java.util包,在下文中一共展示了AbstractList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSpinnerTouchListener
import java.util.AbstractList; //导入依赖的package包/类
@OnTouch(R.id.spinner_font_names)
protected boolean onSpinnerTouchListener(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
if (currentSelectedFont != null && builderPickerDialog != null) {
//to update currently selected font
builderPickerDialog.setInputs(new UniversalPickerDialog.Input(currentFontIndex,
(AbstractList<String>) fontNames));
builderPickerDialog.show();
} else {
//fallback plan
presenter.loadFontsAvailable();
setFontPickerDialog();
}
}
return true;
}
示例2: testGetRecentConnections
import java.util.AbstractList; //导入依赖的package包/类
public void testGetRecentConnections() throws Exception {
String section = "remote.platforms";
ExecutionEnvironment[] envs = NativeExecutionTestSupport.getTestExecutionEnvironmentsFromSection(section);
assertTrue("Empty environmens list for section ", envs.length > 0);
ConnectionManager.getInstance().clearRecentConnectionsList();
AbstractList<ExecutionEnvironment> referenceList = new ArrayList<>();
for (ExecutionEnvironment env : envs) {
ConnectionManager.getInstance().updateRecentConnectionsList(env);
referenceList.add(0, env);
}
List<ExecutionEnvironment> managersList = ConnectionManager.getInstance().getRecentConnections();
assertEquals("Connections lists differ", referenceList, managersList);
ConnectionManager.getInstance().clearRecentConnectionsList();
assertTrue("Recent connections list should be empty", ConnectionManager.getInstance().getRecentConnections().isEmpty());
ConnectionManager.getInstance().restoreRecentConnectionsList();
assertEquals("Restopred connections list differ", referenceList, managersList);
}
示例3: getValues
import java.util.AbstractList; //导入依赖的package包/类
@Override
public List getValues() {
final List origValues = buffer.getValues();
return new AbstractList() {
@Override
public Object get(int index) {
return origValues.get(rawOffset(index));
}
@Override
public int size() {
return getLength();
}
};
}
示例4: getInstances
import java.util.AbstractList; //导入依赖的package包/类
@Override
public List<ObjectVariable> getInstances(long maxInstances) {
//assert !java.awt.EventQueue.isDispatchThread() : "Instances retrieving in AWT Event Queue!";
final List<ObjectReference> instances;
try {
instances = ReferenceTypeWrapper.instances(classType, maxInstances);
} catch (ObjectCollectedExceptionWrapper | VMDisconnectedExceptionWrapper |
InternalExceptionWrapper ex) {
return Collections.emptyList();
}
return new AbstractList<ObjectVariable>() {
@Override
public ObjectVariable get(int i) {
ObjectReference obj = instances.get(i);
return new AbstractObjectVariable(debugger, obj, classType.name()+" instance "+i);
}
@Override
public int size() {
return instances.size();
}
};
}
示例5: iterable
import java.util.AbstractList; //导入依赖的package包/类
private static Iterable<Object> iterable(
final Object first, final Object second, final Object[] rest) {
checkNotNull(rest);
return new AbstractList<Object>() {
@Override public int size() {
return rest.length + 2;
}
@Override public Object get(int index) {
switch (index) {
case 0:
return first;
case 1:
return second;
default:
return rest[index - 2];
}
}
};
}
示例6: convertBack
import java.util.AbstractList; //导入依赖的package包/类
/**
* Convert the internal {@link List} of values back to a user-friendly list.
* Integers are kept as-is since the terms query does not make any difference
* between {@link Integer}s and {@link Long}s, but {@link BytesRef}s are
* converted back to {@link String}s.
*/
static List<Object> convertBack(List<?> list) {
return new AbstractList<Object>() {
@Override
public int size() {
return list.size();
}
@Override
public Object get(int index) {
Object o = list.get(index);
if (o instanceof BytesRef) {
o = ((BytesRef) o).utf8ToString();
}
// we do not convert longs, all integer types are equivalent
// as far as this query is concerned
return o;
}
};
}
示例7: jlaStackTrace
import java.util.AbstractList; //导入依赖的package包/类
@GwtIncompatible // invokeAccessibleNonThrowingMethod
private static List<StackTraceElement> jlaStackTrace(final Throwable t) {
checkNotNull(t);
/*
* TODO(cpovirk): Consider optimizing iterator() to catch IOOBE instead of doing bounds checks.
*
* TODO(cpovirk): Consider the UnsignedBytes pattern if it performs faster and doesn't cause
* AOSP grief.
*/
return new AbstractList<StackTraceElement>() {
@Override
public StackTraceElement get(int n) {
return (StackTraceElement)
invokeAccessibleNonThrowingMethod(getStackTraceElementMethod, jla, t, n);
}
@Override
public int size() {
return (Integer) invokeAccessibleNonThrowingMethod(getStackTraceDepthMethod, jla, t);
}
};
}
示例8: iterable
import java.util.AbstractList; //导入依赖的package包/类
private static Iterable<Object> iterable(
final Object first, final Object second, final Object[] rest) {
checkNotNull(rest);
return new AbstractList<Object>() {
@Override
public int size() {
return rest.length + 2;
}
@Override
public Object get(int index) {
switch (index) {
case 0:
return first;
case 1:
return second;
default:
return rest[index - 2];
}
}
};
}
示例9: testsForAbstractList
import java.util.AbstractList; //导入依赖的package包/类
public Test testsForAbstractList() {
return ListTestSuiteBuilder.using(
new TestStringListGenerator() {
@Override
protected List<String> create(final String[] elements) {
return new AbstractList<String>() {
@Override
public int size() {
return elements.length;
}
@Override
public String get(int index) {
return elements[index];
}
};
}
})
.named("AbstractList")
.withFeatures(
CollectionFeature.NONE, CollectionFeature.ALLOWS_NULL_VALUES, CollectionSize.ANY)
.suppressing(suppressForAbstractList())
.createTestSuite();
}
示例10: testAddAll_largeList
import java.util.AbstractList; //导入依赖的package包/类
public void testAddAll_largeList() {
final List<String> list = ImmutableList.of("one", "two", "three", "four", "five");
List<String> misbehavingList =
new AbstractList<String>() {
@Override
public int size() {
return list.size();
}
@Override
public String get(int index) {
if (index < 2) {
throw new AssertionError();
}
return list.get(index);
}
};
EvictingQueue<String> queue = EvictingQueue.create(3);
assertTrue(queue.addAll(misbehavingList));
assertEquals("three", queue.remove());
assertEquals("four", queue.remove());
assertEquals("five", queue.remove());
assertTrue(queue.isEmpty());
}
示例11: getAllObjKeys
import java.util.AbstractList; //导入依赖的package包/类
public List<Long> getAllObjKeys() {
return new AbstractList<Long>() {
@Override
public Long get(int index) {
if (index == 0) {
return primaryObjKey;
}
return fallBackObjKeys.get(index - 1);
}
@Override
public Spliterator<Long> spliterator() {
return super.spliterator();
}
@Override
public int size() {
return fallBackObjKeys.size() + 1;
}
};
}
示例12: twosComplementBits
import java.util.AbstractList; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @see kodkod.engine.bool.Int#twosComplementBits()
*/
@Override
public final List<BooleanValue> twosComplementBits() {
return new AbstractList<BooleanValue>() {
@Override
public BooleanValue get(int i) {
if (i < 0 || i >= factory.bitwidth)
throw new IndexOutOfBoundsException();
return bit(i);
}
@Override
public int size() {
return factory.bitwidth;
}
};
}
示例13: checkUnusedProperties
import java.util.AbstractList; //导入依赖的package包/类
/**
* Report errors for unused propOrder entries.
*/
public void checkUnusedProperties() {
for( int i=0; i<used.length; i++ )
if(used[i]==null) {
String unusedName = propOrder[i];
String nearest = EditDistance.findNearest(unusedName, new AbstractList<String>() {
public String get(int index) {
return properties.get(index).getName();
}
public int size() {
return properties.size();
}
});
boolean isOverriding = (i > (properties.size()-1)) ? false : properties.get(i).hasAnnotation(OverrideAnnotationOf.class);
if (!isOverriding) {
builder.reportError(new IllegalAnnotationException(
Messages.PROPERTY_ORDER_CONTAINS_UNUSED_ENTRY.format(unusedName,nearest),ClassInfoImpl.this));
}
}
}
示例14: getAllHeaderLines
import java.util.AbstractList; //导入依赖的package包/类
/**
* Return all the header lines as a collection
*
* @return list of header lines.
*/
public List<String> getAllHeaderLines() {
if (headerValueView == null)
headerValueView = new AbstractList<String>() {
@Override
public String get(int index) {
return headers.get(index).line;
}
@Override
public int size() {
return headers.size();
}
};
return headerValueView;
}
示例15: populate
import java.util.AbstractList; //导入依赖的package包/类
/**
* Populates this list with all prefix strings of a given string. All
* of the prefix strings share the same backing array of chars.
*/
private synchronized void populate(int newSize) {
final int size = size();
if (newSize <= size) {
return;
}
final char[] chars = new char[newSize];
Arrays.fill(chars, ' ');
final int length = newSize - size;
final int offset = size;
// addAll is much more efficient than repeated add for
// CopyOnWriteArrayList
addAll(
new AbstractList<String>() {
public String get(int index) {
return new String(chars, 0, offset + index);
}
public int size() {
return length;
}
});
}