Search in sources :

Example 51 with AbstractList

use of java.util.AbstractList in project neo4j by neo4j.

the class DependenciesTest method givenSatisfiedTypeWhenResolveWithSuperTypeThenInstanceReturned.

@Test
public void givenSatisfiedTypeWhenResolveWithSuperTypeThenInstanceReturned() throws Exception {
    // Given
    Dependencies dependencies = new Dependencies();
    AbstractList foo = new ArrayList();
    dependencies.satisfyDependency(foo);
    // When
    AbstractList instance = dependencies.resolveDependency(AbstractList.class);
    // Then
    assertThat(instance, equalTo(foo));
}
Also used : AbstractList(java.util.AbstractList) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 52 with AbstractList

use of java.util.AbstractList in project camel by apache.

the class CxfPayload method getBody.

/**
     * Get the body as a List of DOM elements. 
     * This will cause the Body to be fully read and parsed.
     * @return
     */
public List<Element> getBody() {
    return new AbstractList<Element>() {

        public boolean add(Element e) {
            return body.add(new DOMSource(e));
        }

        public Element set(int index, Element element) {
            Source s = body.set(index, new DOMSource(element));
            try {
                return StaxUtils.read(s).getDocumentElement();
            } catch (XMLStreamException e) {
                throw new RuntimeCamelException("Problem converting content to Element", e);
            }
        }

        public void add(int index, Element element) {
            body.add(index, new DOMSource(element));
        }

        public Element remove(int index) {
            Source s = body.remove(index);
            try {
                return StaxUtils.read(s).getDocumentElement();
            } catch (XMLStreamException e) {
                throw new RuntimeCamelException("Problem converting content to Element", e);
            }
        }

        public Element get(int index) {
            Source s = body.get(index);
            try {
                Element el = StaxUtils.read(s).getDocumentElement();
                addNamespace(el, nsMap);
                body.set(index, new DOMSource(el));
                return el;
            } catch (Exception ex) {
                throw new RuntimeCamelException("Problem converting content to Element", ex);
            }
        }

        public int size() {
            return body.size();
        }
    };
}
Also used : AbstractList(java.util.AbstractList) DOMSource(javax.xml.transform.dom.DOMSource) XMLStreamException(javax.xml.stream.XMLStreamException) Element(org.w3c.dom.Element) RuntimeCamelException(org.apache.camel.RuntimeCamelException) DOMSource(javax.xml.transform.dom.DOMSource) Source(javax.xml.transform.Source) RuntimeCamelException(org.apache.camel.RuntimeCamelException) XMLStreamException(javax.xml.stream.XMLStreamException)

Example 53 with AbstractList

use of java.util.AbstractList in project GeoGig by boundlessgeo.

the class GeogigFeatureStore method addFeatures.

@Override
public final List<FeatureId> addFeatures(FeatureCollection<SimpleFeatureType, SimpleFeature> featureCollection) throws IOException {
    if (Transaction.AUTO_COMMIT.equals(getTransaction())) {
        throw new UnsupportedOperationException("GeoGIG does not support AUTO_COMMIT");
    }
    Preconditions.checkState(getDataStore().isAllowTransactions(), "Transactions not supported; head is not a local branch");
    final WorkingTree workingTree = delegate.getWorkingTree();
    final String path = delegate.getTypeTreePath();
    ProgressListener listener = new DefaultProgressListener();
    final List<FeatureId> insertedFids = Lists.newArrayList();
    List<Node> deferringTarget = new AbstractList<Node>() {

        @Override
        public boolean add(Node node) {
            String fid = node.getName();
            String version = node.getObjectId().toString();
            insertedFids.add(new FeatureIdVersionedImpl(fid, version));
            return true;
        }

        @Override
        public Node get(int index) {
            throw new UnsupportedOperationException();
        }

        @Override
        public int size() {
            return 0;
        }
    };
    Integer count = (Integer) null;
    FeatureIterator<SimpleFeature> featureIterator = featureCollection.features();
    try {
        Iterator<SimpleFeature> features;
        features = new FeatureIteratorIterator<SimpleFeature>(featureIterator);
        /*
             * Make sure to transform the incoming features to the native schema to avoid situations
             * where geogig would change the metadataId of the RevFeature nodes due to small
             * differences in the default and incoming schema such as namespace or missing
             * properties
             */
        final SimpleFeatureType nativeSchema = delegate.getNativeType();
        features = Iterators.transform(features, new SchemaInforcer(nativeSchema));
        workingTree.insert(path, features, listener, deferringTarget, count);
    } catch (Exception e) {
        throw new IOException(e);
    } finally {
        featureIterator.close();
    }
    return insertedFids;
}
Also used : AbstractList(java.util.AbstractList) Node(org.locationtech.geogig.api.Node) DefaultProgressListener(org.locationtech.geogig.api.DefaultProgressListener) IOException(java.io.IOException) SimpleFeature(org.opengis.feature.simple.SimpleFeature) IOException(java.io.IOException) FeatureId(org.opengis.filter.identity.FeatureId) WorkingTree(org.locationtech.geogig.repository.WorkingTree) DefaultProgressListener(org.locationtech.geogig.api.DefaultProgressListener) ProgressListener(org.locationtech.geogig.api.ProgressListener) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) FeatureIdVersionedImpl(org.geotools.filter.identity.FeatureIdVersionedImpl)

Example 54 with AbstractList

use of java.util.AbstractList in project streamsupport by stefan-zobel.

the class MOAT method testList.

private static void testList(final List<Integer> l) {
    // ----------------------------------------------------------------
    try {
        l.addAll(-1, Collections.<Integer>emptyList());
        fail("Expected IndexOutOfBoundsException not thrown");
    } catch (UnsupportedOperationException ignored) {
    /* OK */
    } catch (IndexOutOfBoundsException ignored) {
    /* OK */
    } catch (Throwable t) {
        unexpected(t);
    }
    // l.subList(0,0) instanceof Serializable);
    if (l.subList(0, 0) instanceof Serializable)
        check(l instanceof Serializable);
    equal(l instanceof RandomAccess, l.subList(0, 0) instanceof RandomAccess);
    l.iterator();
    l.listIterator();
    l.listIterator(0);
    l.listIterator(l.size());
    THROWS(IndexOutOfBoundsException.class, () -> l.listIterator(-1), () -> l.listIterator(l.size() + 1));
    if (l instanceof AbstractList) {
        try {
            int size = l.size();
            AbstractList<Integer> abList = (AbstractList<Integer>) l;
            Method m = AbstractList.class.getDeclaredMethod("removeRange", new Class[] { int.class, int.class });
            m.setAccessible(true);
            m.invoke(abList, new Object[] { 0, 0 });
            m.invoke(abList, new Object[] { size, size });
            equal(size, l.size());
        } catch (UnsupportedOperationException ignored) {
        /* OK */
        } catch (Exception ex) {
            // jdk9 module system may deny access
            if (ex.getClass().getSimpleName().equals("InaccessibleObjectException")) {
                return;
            /* OK */
            }
            unexpected(ex);
        } catch (Throwable t) {
            unexpected(t);
        }
    }
}
Also used : AbstractList(java.util.AbstractList) Serializable(java.io.Serializable) RandomAccess(java.util.RandomAccess) Method(java.lang.reflect.Method) NoSuchElementException(java.util.NoSuchElementException) IOException(java.io.IOException) NotSerializableException(java.io.NotSerializableException)

Example 55 with AbstractList

use of java.util.AbstractList in project alfresco-remote-api by Alfresco.

the class GroupsImpl method getGroupMembers.

public CollectionWithPagingInfo<GroupMember> getGroupMembers(String groupId, final Parameters parameters) {
    validateGroupId(groupId, false);
    // Not allowed to list all members.
    if (PermissionService.ALL_AUTHORITIES.equals(groupId)) {
        throw new UnsupportedResourceOperationException();
    }
    Paging paging = parameters.getPaging();
    // Retrieve sort column. This is limited for now to sort column due to
    // v0 api implementation. Should be improved in the future.
    Pair<String, Boolean> sortProp = getGroupsSortProp(parameters);
    AuthorityType authorityType = null;
    // Parse where clause properties.
    Query q = parameters.getQuery();
    if (q != null) {
        MapBasedQueryWalkerOrSupported propertyWalker = new MapBasedQueryWalkerOrSupported(LIST_GROUP_MEMBERS_QUERY_PROPERTIES, null);
        QueryHelper.walk(q, propertyWalker);
        String memberTypeStr = propertyWalker.getProperty(PARAM_MEMBER_TYPE, WhereClauseParser.EQUALS, String.class);
        authorityType = getAuthorityType(memberTypeStr);
    }
    PagingResults<AuthorityInfo> pagingResult = getAuthoritiesInfo(authorityType, groupId, sortProp, paging);
    // Create response.
    final List<AuthorityInfo> page = pagingResult.getPage();
    int totalItems = pagingResult.getTotalResultCount().getFirst();
    List<GroupMember> groupMembers = new AbstractList<GroupMember>() {

        @Override
        public GroupMember get(int index) {
            AuthorityInfo authorityInfo = page.get(index);
            return getGroupMember(authorityInfo);
        }

        @Override
        public int size() {
            return page.size();
        }
    };
    return CollectionWithPagingInfo.asPaged(paging, groupMembers, pagingResult.hasMoreItems(), totalItems);
}
Also used : AbstractList(java.util.AbstractList) GroupMember(org.alfresco.rest.api.model.GroupMember) Query(org.alfresco.rest.framework.resource.parameters.where.Query) UnsupportedResourceOperationException(org.alfresco.rest.framework.core.exceptions.UnsupportedResourceOperationException) Paging(org.alfresco.rest.framework.resource.parameters.Paging) AuthorityType(org.alfresco.service.cmr.security.AuthorityType) AuthorityInfo(org.alfresco.repo.security.authority.AuthorityInfo) MapBasedQueryWalkerOrSupported(org.alfresco.rest.workflow.api.impl.MapBasedQueryWalkerOrSupported)

Aggregations

AbstractList (java.util.AbstractList)76 ArrayList (java.util.ArrayList)30 List (java.util.List)17 HashMap (java.util.HashMap)10 NodeRef (org.alfresco.service.cmr.repository.NodeRef)10 QName (org.alfresco.service.namespace.QName)9 UserInfo (org.alfresco.rest.api.model.UserInfo)8 FileInfo (org.alfresco.service.cmr.model.FileInfo)8 WebApiDescription (org.alfresco.rest.framework.WebApiDescription)7 RexNode (org.apache.calcite.rex.RexNode)7 Collection (java.util.Collection)6 ConcurrentModificationException (java.util.ConcurrentModificationException)6 Iterator (java.util.Iterator)6 Paging (org.alfresco.rest.framework.resource.parameters.Paging)6 IOException (java.io.IOException)5 Set (java.util.Set)5 FilterProp (org.alfresco.repo.node.getchildren.FilterProp)5 Test (org.junit.Test)5 ListIterator (java.util.ListIterator)4 RandomAccess (java.util.RandomAccess)4