List of usage examples for java.util AbstractList AbstractList
protected AbstractList()
From source file:org.orekit.files.ccsds.OEMFile.java
/** {@inheritDoc} */ @Override//from w w w .j a v a 2 s .c o m public List<SatelliteTimeCoordinate> getSatelliteCoordinates(final String satId) { // first we collect all available EphemeridesBlocks for this satellite // and return a list view of the actual EphemeridesBlocks transforming the // EphemeridesDataLines into SatelliteTimeCoordinates in a lazy manner. final List<Pair<Integer, Integer>> ephemeridesBlockMapping = new ArrayList<Pair<Integer, Integer>>(); final ListIterator<EphemeridesBlock> it = ephemeridesBlocks.listIterator(); int totalDataLines = 0; while (it.hasNext()) { final int index = it.nextIndex(); final EphemeridesBlock block = it.next(); if (block.getMetaData().getObjectID().equals(satId)) { final int dataLines = block.getEphemeridesDataLines().size(); totalDataLines += dataLines; ephemeridesBlockMapping.add(new Pair<Integer, Integer>(index, dataLines)); } } // the total number of coordinates for this satellite final int totalNumberOfCoordinates = totalDataLines; return new AbstractList<SatelliteTimeCoordinate>() { @Override public SatelliteTimeCoordinate get(final int index) { if (index < 0 || index >= size()) { throw new IndexOutOfBoundsException(); } // find the corresponding ephemerides block and data line int ephemeridesBlockIndex = -1; int dataLineIndex = index; for (Pair<Integer, Integer> pair : ephemeridesBlockMapping) { if (dataLineIndex < pair.getValue()) { ephemeridesBlockIndex = pair.getKey(); break; } else { dataLineIndex -= pair.getValue(); } } if (ephemeridesBlockIndex == -1 || dataLineIndex == -1) { throw new IndexOutOfBoundsException(); } final EphemeridesDataLine dataLine = ephemeridesBlocks.get(ephemeridesBlockIndex) .getEphemeridesDataLines().get(dataLineIndex); final CartesianOrbit orbit = dataLine.getOrbit(); return new SatelliteTimeCoordinate(orbit.getDate(), orbit.getPVCoordinates()); } @Override public int size() { return totalNumberOfCoordinates; } }; }
From source file:MiniMap.java
/** * @see java.util.Map#values()/* w ww .j a v a2 s. com*/ */ public Collection<V> values() { return new AbstractList<V>() { @Override public V get(final int index) { if (index > size - 1) { throw new IndexOutOfBoundsException(); } int keyIndex = nextKey(0); for (int i = 0; i < index; i++) { keyIndex = nextKey(keyIndex + 1); } return values[keyIndex]; } @Override public int size() { return size; } }; }
From source file:no.ssb.jsonstat.v2.deser.DatasetDeserializer.java
List<Number> parseValues(JsonParser p, DeserializationContext ctxt) throws IOException { List<Number> result = Collections.emptyList(); switch (p.getCurrentToken()) { case START_OBJECT: SortedMap<Integer, Number> map = p.readValueAs(VALUES_MAP); result = new AbstractList<Number>() { @Override//from ww w . j av a 2 s . c o m public int size() { return map.lastKey() + 1; } @Override public Number get(int index) { return map.get(index); } }; break; case START_ARRAY: result = p.readValueAs(VALUES_LIST); break; default: ctxt.handleUnexpectedToken(this._valueClass, p.getCurrentToken(), p, "msg"); } return result; }
From source file:de.codesourcery.eve.apiclient.utils.XMLParseHelper.java
public static List<Element> selectElements(Document doc, XPathExpression expr, boolean isRequired) { final NodeList result; try {/*www. j a va 2 s . co m*/ result = (NodeList) expr.evaluate(doc, XPathConstants.NODESET); } catch (XPathExpressionException e) { throw new RuntimeException("Internal error while evaluating XPath expression " + expr, e); } if (result.getLength() == 0) { if (isRequired) { throw new UnparseableResponseException( "Unexpected response XML," + " XPath expression returned nothing: " + expr); } return Collections.emptyList(); } return new AbstractList<Element>() { @Override public Element get(int index) { return (Element) result.item(index); } @Override public int size() { return result.getLength(); } }; }
From source file:org.alfresco.contentstore.patch.PatchServiceImpl.java
private PatchDocument fromProtoBuf(PatchDocumentProtos.PatchDocument protoBuf) { List<Patch> patches = new AbstractList<Patch>() { @Override//w w w . j ava 2 s . com public Patch get(int index) { PatchDocumentProtos.PatchDocument.Patch patchProtoBuf = protoBuf.getPatchesList().get(index); Patch patch = new Patch(patchProtoBuf.getLastMatchIndex(), patchProtoBuf.getSize(), patchProtoBuf.getBuffer().toByteArray()); return patch; } @Override public int size() { return protoBuf.getPatchesList().size(); } }; String nodeId = protoBuf.getNodeId(); Node node = Node.fromNodeId(nodeId); PatchDocument patchDocument = new PatchDocumentImpl(node, protoBuf.getBlockSize(), protoBuf.getMatchedBlocksList(), patches); return patchDocument; }
From source file:org.terasoluna.gfw.web.el.ObjectToMapConverter.java
/** * Convert any array to {@code List<Object>} * @param arrayObject array to convert/*from w w w. j a va 2 s. c o m*/ * @return list */ private static List<Object> arrayObjectToList(final Object arrayObject) { // 'arrayObject' must be array return new AbstractList<Object>() { @Override public Object get(int index) { return Array.get(arrayObject, index); } @Override public int size() { return Array.getLength(arrayObject); } }; }
From source file:org.briljantframework.data.vector.AbstractVector.java
@Override public <T> List<T> toList(Class<T> cls) { return new AbstractList<T>() { @Override//ww w. ja v a2 s . c o m public T get(int index) { return loc().get(cls, index); } @Override public int size() { return AbstractVector.this.size(); } }; }
From source file:org.alfresco.rest.api.tests.TestCMIS.java
private void checkSecondaryTypes(Document doc, Set<String> expectedSecondaryTypes, Set<String> expectedMissingSecondaryTypes) { final List<SecondaryType> secondaryTypesList = doc.getSecondaryTypes(); assertNotNull(secondaryTypesList);//from w ww . j a v a2 s . c o m List<String> secondaryTypes = new AbstractList<String>() { @Override public String get(int index) { SecondaryType type = secondaryTypesList.get(index); return type.getId(); } @Override public int size() { return secondaryTypesList.size(); } }; if (expectedSecondaryTypes != null) { assertTrue("Missing secondary types: " + secondaryTypes, secondaryTypes.containsAll(expectedSecondaryTypes)); } if (expectedMissingSecondaryTypes != null) { assertTrue("Expected missing secondary types but at least one is still present: " + secondaryTypes, !secondaryTypes.containsAll(expectedMissingSecondaryTypes)); } }
From source file:org.alfresco.rest.api.impl.PeopleImpl.java
@Override public CollectionWithPagingInfo<Person> getPeople(final Parameters parameters) { Paging paging = parameters.getPaging(); PagingRequest pagingRequest = Util.getPagingRequest(paging); List<Pair<QName, Boolean>> sortProps = getSortProps(parameters); // For now the results are not filtered // please see REPO-555 final PagingResults<PersonService.PersonInfo> pagingResult = personService.getPeople(null, null, sortProps, pagingRequest);/*from w ww . jav a2s. c om*/ final List<PersonService.PersonInfo> page = pagingResult.getPage(); int totalItems = pagingResult.getTotalResultCount().getFirst(); final String personId = AuthenticationUtil.getFullyAuthenticatedUser(); List<Person> people = new AbstractList<Person>() { @Override public Person get(int index) { PersonService.PersonInfo personInfo = page.get(index); Person person = getPersonWithProperties(personInfo.getUserName(), parameters.getInclude()); return person; } @Override public int size() { return page.size(); } }; return CollectionWithPagingInfo.asPaged(paging, people, pagingResult.hasMoreItems(), totalItems); }
From source file:org.briljantframework.array.AbstractComplexArray.java
@Override public final List<Complex> toList() { return new AbstractList<Complex>() { @Override//from w w w.j a v a 2s . co m public int size() { return AbstractComplexArray.this.size(); } @Override public Complex get(int index) { return AbstractComplexArray.this.get(index); } @Override public Complex set(int index, Complex element) { Complex old = get(index); AbstractComplexArray.this.set(index, element); return old; } }; }