You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by re...@apache.org on 2015/03/19 15:53:46 UTC
[2/3] clerezza git commit: CLEREZZA-961: using rdf-commons from
clerezza-rdf-core repository
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleLiteralFactory.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleLiteralFactory.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleLiteralFactory.java
deleted file mode 100644
index 4a19132..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleLiteralFactory.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.clerezza.rdf.core.impl;
-
-import java.math.BigInteger;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import org.apache.clerezza.rdf.core.InvalidLiteralTypeException;
-import org.apache.clerezza.rdf.core.LiteralFactory;
-import org.apache.clerezza.rdf.core.NoConvertorException;
-import org.apache.commons.rdf.Iri;
-import org.apache.clerezza.rdf.core.impl.util.Base64;
-import org.apache.clerezza.rdf.core.impl.util.W3CDateFormat;
-import org.apache.commons.rdf.Literal;
-
-/**
- * An implementation of literal factory currently supporting only
- * byte[]/base64Binary and Java.util.Date/date
- *
- * @author reto
- */
-
-public class SimpleLiteralFactory extends LiteralFactory {
-
- private static final String XSD = "http://www.w3.org/2001/XMLSchema#";
- final private static Iri xsdInteger = xsd("integer");
- final private static Iri xsdInt = xsd("int");
- final private static Iri xsdShort = xsd("short");
- final private static Iri xsdByte = xsd("byte");
- final private static Iri xsdLong = xsd("long");
-
-
- final private static Set<Iri> decimalTypes = new HashSet<Iri>();
-
- final private static Map<Class<?>, TypeConverter<?>> typeConverterMap = new HashMap<Class<?>, TypeConverter<?>>();
- final static Class<? extends byte[]> byteArrayType;
-
- static {
- Collections.addAll(decimalTypes, xsdInteger, xsdInt, xsdByte, xsdShort, xsdLong );
-
- byte[] byteArray = new byte[0];
- byteArrayType = byteArray.getClass();
- typeConverterMap.put(byteArrayType, new ByteArrayConverter());
- typeConverterMap.put(Date.class, new DateConverter());
- typeConverterMap.put(Boolean.class, new BooleanConverter());
- typeConverterMap.put(String.class, new StringConverter());
- typeConverterMap.put(Integer.class, new IntegerConverter());
- typeConverterMap.put(BigInteger.class, new BigIntegerConverter());
- typeConverterMap.put(Long.class, new LongConverter());
- typeConverterMap.put(Double.class, new DoubleConverter());
- typeConverterMap.put(Float.class, new FloatConverter());
- typeConverterMap.put(Iri.class, new UriRefConverter());
- }
-
- final private static Iri xsdDouble =xsd("double");
- final private static Iri xsdFloat =xsd("float");
- final private static Iri xsdAnyURI =xsd("anyURI");
-
- final private static Iri xsd(String name) {
- return new Iri(XSD+name);
- }
-
- private static interface TypeConverter<T> {
- Literal createLiteral(T value);
- T createObject(Literal literal);
- }
-
- private static class ByteArrayConverter implements TypeConverter<byte[]> {
-
- private static final Iri base64Uri =xsd("base64Binary");
-
- @Override
- public Literal createLiteral(byte[] value) {
- return new TypedLiteralImpl(Base64.encode((byte[]) value), base64Uri);
- }
-
- @Override
- public byte[] createObject(Literal literal) {
- if (!literal.getDataType().equals(base64Uri)) {
- throw new InvalidLiteralTypeException(byteArrayType, literal.getDataType());
- }
- return (byte[])Base64.decode(literal.getLexicalForm());
- }
-
-
- }
- private static class DateConverter implements TypeConverter<Date> {
-
- private static final Iri dateTimeUri =xsd("dateTime");
- private static final DateFormat DATE_FORMAT = new W3CDateFormat();
-
- @Override
- public Literal createLiteral(Date value) {
- return new TypedLiteralImpl(DATE_FORMAT.format(value), dateTimeUri);
- }
-
- @Override
- public Date createObject(Literal literal) {
- if (!literal.getDataType().equals(dateTimeUri)) {
- throw new InvalidLiteralTypeException(Date.class, literal.getDataType());
- }
- try {
- return DATE_FORMAT.parse(literal.getLexicalForm());
- } catch (ParseException ex) {
- throw new RuntimeException("Exception parsing literal as date", ex);
- }
- }
-
-
- }
-
- private static class BooleanConverter implements TypeConverter<Boolean> {
-
- private static final Iri booleanUri =xsd("boolean");
- public static final TypedLiteralImpl TRUE = new TypedLiteralImpl("true", booleanUri);
- public static final TypedLiteralImpl FALSE = new TypedLiteralImpl("false", booleanUri);
-
- @Override
- public Literal createLiteral(Boolean value) {
- if (value) return TRUE;
- else return FALSE;
- }
-
- @Override
- public Boolean createObject(Literal literal) {
- if (literal == TRUE) return true;
- else if (literal == FALSE) return false;
- else if (!literal.getDataType().equals(booleanUri)) {
- throw new InvalidLiteralTypeException(Boolean.class, literal.getDataType());
- }
- return Boolean.valueOf(literal.getLexicalForm());
- }
- }
-
- private static class StringConverter implements TypeConverter<String> {
-
- private static final Iri stringUri =xsd("string");
-
- @Override
- public Literal createLiteral(String value) {
- return new TypedLiteralImpl(value, stringUri);
- }
-
- @Override
- public String createObject(Literal literal) {
- if (!literal.getDataType().equals(stringUri)) {
- throw new InvalidLiteralTypeException(String.class, literal.getDataType());
- }
- return literal.getLexicalForm();
- }
- }
-
- private static class IntegerConverter implements TypeConverter<Integer> {
-
-
- @Override
- public Literal createLiteral(Integer value) {
- return new TypedLiteralImpl(value.toString(), xsdInt);
- }
-
- @Override
- public Integer createObject(Literal literal) {
- if (!decimalTypes.contains(literal.getDataType())) {
- throw new InvalidLiteralTypeException(Integer.class, literal.getDataType());
- }
- return new Integer(literal.getLexicalForm());
- }
- }
-
- private static class LongConverter implements TypeConverter<Long> {
-
-
-
- @Override
- public Literal createLiteral(Long value) {
- return new TypedLiteralImpl(value.toString(), xsdLong);
- }
-
- @Override
- public Long createObject(Literal literal) {
- if (!decimalTypes.contains(literal.getDataType())) {
- throw new InvalidLiteralTypeException(Long.class, literal.getDataType());
- }
- return new Long(literal.getLexicalForm());
- }
- }
-
-
- private static class FloatConverter implements TypeConverter<Float> {
-
- @Override
- public Literal createLiteral(Float value) {
- return new TypedLiteralImpl(value.toString(), xsdFloat);
- }
-
- @Override
- public Float createObject(Literal literal) {
- if (!literal.getDataType().equals(xsdFloat)) {
- throw new InvalidLiteralTypeException(Float.class, literal.getDataType());
- }
- return Float.valueOf(literal.getLexicalForm());
- }
- }
-
- private static class DoubleConverter implements TypeConverter<Double> {
-
-
-
- @Override
- public Literal createLiteral(Double value) {
- return new TypedLiteralImpl(value.toString(), xsdDouble);
- }
-
- @Override
- public Double createObject(Literal literal) {
- if (!literal.getDataType().equals(xsdDouble)) {
- throw new InvalidLiteralTypeException(Double.class, literal.getDataType());
- }
- return new Double(literal.getLexicalForm());
- }
- }
-
- private static class BigIntegerConverter implements TypeConverter<BigInteger> {
-
-
-
- @Override
- public Literal createLiteral(BigInteger value) {
- return new TypedLiteralImpl(value.toString(), xsdInteger);
- }
-
- @Override
- public BigInteger createObject(Literal literal) {
- if (!literal.getDataType().equals(xsdInteger)) {
- throw new InvalidLiteralTypeException(Double.class, literal.getDataType());
- }
- return new BigInteger(literal.getLexicalForm());
- }
- }
-
- private static class UriRefConverter implements TypeConverter<Iri> {
-
-
-
- @Override
- public Literal createLiteral(Iri value) {
- return new TypedLiteralImpl(value.getUnicodeString(), xsdAnyURI);
- }
-
- @Override
- public Iri createObject(Literal literal) {
- if (!literal.getDataType().equals(xsdAnyURI)) {
- throw new InvalidLiteralTypeException(Iri.class, literal.getDataType());
- }
- return new Iri(literal.getLexicalForm());
- }
- }
-
-
- @SuppressWarnings("unchecked")
- @Override
- public Literal createTypedLiteral(Object value) throws NoConvertorException {
- TypeConverter converter = getConverterFor(value.getClass());
- return converter.createLiteral(value);
- }
-
-
-
- @Override
- public <T> T createObject(Class<T> type, Literal literal)
- throws NoConvertorException, InvalidLiteralTypeException {
- final TypeConverter<T> converter = getConverterFor(type);
- return converter.createObject(literal);
-
- }
-
- @SuppressWarnings("unchecked")
- private <T> TypeConverter<T> getConverterFor(Class<T> type) throws NoConvertorException {
- TypeConverter<T> convertor = (TypeConverter<T>) typeConverterMap.get(type);
- if (convertor != null) {
- return convertor;
- }
- for (Map.Entry<Class<?>, TypeConverter<?>> converterEntry : typeConverterMap.entrySet()) {
- if (type.isAssignableFrom(converterEntry.getKey())) {
- return (TypeConverter<T>) converterEntry.getValue();
- }
- }
- throw new NoConvertorException(type);
- }
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleMGraph.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleMGraph.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleMGraph.java
deleted file mode 100644
index 19a4b72..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/SimpleMGraph.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.clerezza.rdf.core.impl;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.apache.commons.rdf.ImmutableGraph;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.Triple;
-
-/**
- *
- * @author reto
- */
-public class SimpleMGraph extends SimpleGraph implements Graph {
-
- /**
- * Creates an empty SimpleMGraph
- */
- public SimpleMGraph() {
- }
-
- public SimpleMGraph(Set<Triple> baseSet) {
- super(baseSet);
- }
-
- public SimpleMGraph(Collection<Triple> baseCollection) {
- super(baseCollection);
- }
-
- public SimpleMGraph(Iterator<Triple> iterator) {
- super(iterator);
- }
-
-}
-
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/TripleImpl.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/TripleImpl.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/TripleImpl.java
deleted file mode 100644
index e41bbd0..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/TripleImpl.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.clerezza.rdf.core.impl;
-
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Iri;
-
-/**
- *
- * @author reto
- */
-public class TripleImpl implements Triple {
-
- private final BlankNodeOrIri subject;
- private final Iri predicate;
- private final RdfTerm object;
-
- /**
- * Creates a new <code>TripleImpl</code>.
- *
- * @param subject the subject.
- * @param predicate the predicate.
- * @param object the object.
- * @throws IllegalArgumentException if an attribute is <code>null</code>.
- */
- public TripleImpl(BlankNodeOrIri subject, Iri predicate, RdfTerm object) {
- if (subject == null) {
- throw new IllegalArgumentException("Invalid subject: null");
- } else if (predicate == null) {
- throw new IllegalArgumentException("Invalid predicate: null");
- } else if (object == null) {
- throw new IllegalArgumentException("Invalid object: null");
- }
- this.subject = subject;
- this.predicate = predicate;
- this.object = object;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof Triple)) {
- return false;
- }
- final Triple other = (Triple) obj;
- if (!this.subject.equals(other.getSubject())) {
- return false;
- }
- if (!this.predicate.equals(other.getPredicate())) {
- return false;
- }
- if (!this.object.equals(other.getObject())) {
- return false;
- }
- return true;
- }
-
- @Override
- public int hashCode() {
- return (subject.hashCode() >> 1) ^ predicate.hashCode() ^ (object.hashCode() << 1);
- }
-
- @Override
- public BlankNodeOrIri getSubject() {
- return subject;
- }
-
- public Iri getPredicate() {
- return predicate;
- }
-
- public RdfTerm getObject() {
- return object;
- }
-
- @Override
- public String toString() {
- return subject + " " + predicate + " " + object + ".";
- }
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/TypedLiteralImpl.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/TypedLiteralImpl.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/TypedLiteralImpl.java
deleted file mode 100644
index ded5097..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/TypedLiteralImpl.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.clerezza.rdf.core.impl;
-
-import java.io.Serializable;
-
-import org.apache.commons.rdf.Iri;
-import org.apache.commons.rdf.Language;
-import org.apache.commons.rdf.Literal;
-
-/**
- *
- * @author reto
- */
-public class TypedLiteralImpl implements Literal, Serializable {
- private String lexicalForm;
- private Iri dataType;
- private int hashCode;
-
- /**
- * @param lexicalForm
- * @param dataType
- */
- public TypedLiteralImpl(String lexicalForm, Iri dataType) {
- this.lexicalForm = lexicalForm;
- this.dataType = dataType;
- this.hashCode = lexicalForm.hashCode()+dataType.hashCode();
- }
-
- public Iri getDataType() {
- return dataType;
- }
-
- /* (non-Javadoc)
- * @see org.apache.clerezza.rdf.core.LiteralNode#getLexicalForm()
- */
- @Override
- public String getLexicalForm() {
- return lexicalForm;
- }
-
- @Override
- public int hashCode() {
- return hashCode;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof Literal) {
- Literal other = (Literal) obj;
- if (other.getLanguage() != null) {
- return false;
- }
- boolean res = getDataType().equals(other.getDataType())
- && getLexicalForm().equals(other.getLexicalForm());
- return res;
- } else {
- return false;
- }
- }
-
- @Override
- public String toString() {
- StringBuffer result = new StringBuffer();
- result.append('\"');
- result.append(getLexicalForm());
- result.append('\"');
- result.append("^^");
- result.append(getDataType());
- return result.toString();
- }
-
- @Override
- public Language getLanguage() {
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/WriteBlockedGraph.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/WriteBlockedGraph.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/WriteBlockedGraph.java
index 7812a76..f89ba89 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/WriteBlockedGraph.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/WriteBlockedGraph.java
@@ -31,6 +31,7 @@ import org.apache.clerezza.rdf.core.access.ReadOnlyException;
import org.apache.commons.rdf.ImmutableGraph;
import org.apache.commons.rdf.event.FilterTriple;
import org.apache.commons.rdf.event.GraphListener;
+import org.apache.commons.rdf.impl.utils.AbstractGraph;
/**
*
@@ -41,7 +42,7 @@ import org.apache.commons.rdf.event.GraphListener;
*
* @author tsuy
*/
-public class WriteBlockedGraph extends AbstractCollection<Triple>
+public class WriteBlockedGraph extends AbstractGraph
implements Graph {
private Graph triples;
@@ -51,12 +52,12 @@ public class WriteBlockedGraph extends AbstractCollection<Triple>
}
@Override
- public int size() {
+ protected int performSize() {
return triples.size();
}
@Override
- public Iterator<Triple> filter(final BlankNodeOrIri subject, final Iri predicate, final RdfTerm object) {
+ protected Iterator<Triple> performFilter(BlankNodeOrIri subject, Iri predicate, RdfTerm object) {
final Iterator<Triple> baseIter = triples.filter(subject, predicate, object);
return new Iterator<Triple>() {
@@ -110,22 +111,6 @@ public class WriteBlockedGraph extends AbstractCollection<Triple>
}
@Override
- public void addGraphListener(GraphListener listener, FilterTriple filter,
- long delay) {
- triples.addGraphListener(listener, filter, delay);
- }
-
- @Override
- public void addGraphListener(GraphListener listener, FilterTriple filter) {
- triples.addGraphListener(listener, filter);
- }
-
- @Override
- public void removeGraphListener(GraphListener listener) {
- triples.removeGraphListener(listener);
- }
-
- @Override
public Iterator iterator() {
return filter(null, null, null);
}
@@ -134,4 +119,5 @@ public class WriteBlockedGraph extends AbstractCollection<Triple>
public ImmutableGraph getImmutableGraph() {
return this.triples.getImmutableGraph();
}
+
}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/WriteBlockedMGraph.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/WriteBlockedMGraph.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/WriteBlockedMGraph.java
deleted file mode 100644
index 129a803..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/WriteBlockedMGraph.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.clerezza.rdf.core.impl;
-
-import java.util.concurrent.locks.ReadWriteLock;
-import org.apache.commons.rdf.ImmutableGraph;
-import org.apache.clerezza.rdf.core.access.LockableMGraph;
-
-
-/**
-*
-* This is a wrapper object for <code>Graph</code>. If <code>SecurityManger</code>
-* is not <code>null</code> <code>TcManager</code> checks the <code>TcPermission</code>.
-* If read-only permissions are set this wrapper is used instead of <code>Graph</code>.
-*
-* @author tsuy
-*/
-public class WriteBlockedMGraph extends WriteBlockedGraph
- implements LockableMGraph {
-
- private LockableMGraph graph;
- /**
- * Creates a wrapper of <code>SimpleMGraph</code>
- */
- public WriteBlockedMGraph(LockableMGraph graph) {
- super(graph);
- this.graph = graph;
- }
-
- @Override
- public ReadWriteLock getLock() {
- return graph.getLock();
- }
-}
-
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/GraphMatcher.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/GraphMatcher.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/GraphMatcher.java
deleted file mode 100644
index 2ea5389..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/GraphMatcher.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.clerezza.rdf.core.impl.graphmatching;
-
-
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
-import org.apache.clerezza.rdf.core.impl.TripleImpl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author reto
- *
- */
-public class GraphMatcher {
-
-
- private final static Logger log = LoggerFactory.getLogger(GraphMatcher.class);
-
- /**
- * get a mapping from g1 to g2 or null if the graphs are not isomorphic. The
- * returned map maps each <code>BNode</code>s from g1 to one
- * of g2. If the graphs are ground graphs the method return an empty map if
- * the ImmutableGraph are equals and null otherwise.
- * <p/>
- * NOTE: This method does not returned mapping from blank nodes to grounded
- * nodes, a bnode in g1 is not a vraiable that may match any node, but must
- * match a bnode in g2.
- * <p/>
- *
- * On the algorithm:<br/>
- * - In a first step it checked if every grounded triple in g1 matches one
- * in g2<br/>
- * - [optional] blank node blind matching</br>
- * - in a map mbng1 bnode of g1 is mapped to a set of of its
- * properties and inverse properties, this is the predicate and the object
- * or subject respectively, analoguosly in mbgn2 every bnode of g2<br/>
- * - based on the incoming and outgoing properties a hash is calculated for
- * each bnode, in the first step when calculating the hash aconstant value
- * is taken for the bnodes that might be subject or object in the (inverse properties)
- * - hash-classes:
- *
- * @param g1
- * @param g2
- * @return a Set of NodePairs
- */
- public static Map<BlankNode, BlankNode> getValidMapping(Graph og1, Graph og2) {
- Graph g1 = new SimpleMGraph(og1);
- Graph g2 = new SimpleMGraph(og2);
- if (!Utils.removeGrounded(g1,g2)) {
- return null;
- }
- final HashMatching hashMatching;
- try {
- hashMatching = new HashMatching(g1, g2);
- } catch (GraphNotIsomorphicException ex) {
- return null;
- }
- Map<BlankNode, BlankNode> matchings = hashMatching.getMatchings();
- if (g1.size() > 0) {
- //start trial an error matching
- //TODO (CLEREZZA-81) at least in the situation where one matching
- //group is big (approx > 5) we should switch back to hash-based matching
- //after a first guessed matching, rather than try all permutations
- Map<BlankNode, BlankNode> remainingMappings = trialAndErrorMatching(g1, g2, hashMatching.getMatchingGroups());
- if (remainingMappings == null) {
- return null;
- } else {
- matchings.putAll(remainingMappings);
- }
- }
- return matchings;
- }
-
- private static Map<BlankNode, BlankNode> trialAndErrorMatching(Graph g1, Graph g2,
- Map<Set<BlankNode>, Set<BlankNode>> matchingGroups) {
- if (log.isDebugEnabled()) {
- Set<BlankNode> bn1 = Utils.getBNodes(g1);
- log.debug("doing trial and error matching for {} bnodes, " +
- "in graphs of size: {}.", bn1.size(), g1.size());
- }
- Iterator<Map<BlankNode, BlankNode>> mappingIter
- = GroupMappingIterator.create(matchingGroups);
- while (mappingIter.hasNext()) {
- Map<BlankNode, BlankNode> map = mappingIter.next();
- if (checkMapping(g1, g2, map)) {
- return map;
- }
- }
- return null;
- }
-
- private static boolean checkMapping(Graph g1, Graph g2, Map<BlankNode, BlankNode> map) {
- for (Triple triple : g1) {
- if (!g2.contains(map(triple, map))) {
- return false;
- }
- }
- return true;
- }
-
- private static Triple map(Triple triple, Map<BlankNode, BlankNode> map) {
- final BlankNodeOrIri oSubject = triple.getSubject();
-
- BlankNodeOrIri subject = oSubject instanceof BlankNode ?
- map.get((BlankNode)oSubject) : oSubject;
-
- RdfTerm oObject = triple.getObject();
- RdfTerm object = oObject instanceof BlankNode ?
- map.get((BlankNode)oObject) : oObject;
- return new TripleImpl(subject, triple.getPredicate(), object);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/GraphNotIsomorphicException.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/GraphNotIsomorphicException.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/GraphNotIsomorphicException.java
deleted file mode 100644
index 99ae230..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/GraphNotIsomorphicException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.clerezza.rdf.core.impl.graphmatching;
-
-/**
- *
- * @author reto
- */
-class GraphNotIsomorphicException extends Exception {
-
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/GroupMappingIterator.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/GroupMappingIterator.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/GroupMappingIterator.java
deleted file mode 100644
index a032963..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/GroupMappingIterator.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright 2010 reto.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * under the License.
- */
-
-package org.apache.clerezza.rdf.core.impl.graphmatching;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-/**
- * Iterates over all mappings from each element of every Set<T> to each
- * elemenent of their corresponding Set<U>.
- *
- * @author reto
- */
-class GroupMappingIterator<T,U> implements Iterator<Map<T, U>> {
-
- private Iterator<Map<T, U>> firstPartIter;
- private Map<T, U> currentFirstPart;
- final private Map<Set<T>, Set<U>> restMap;
- private Iterator<Map<T, U>> currentRestPartIter;
-
- static <T,U> Iterator<Map<T, U>> create(Map<Set<T>, Set<U>> matchingGroups) {
- if (matchingGroups.size() > 1) {
- return new GroupMappingIterator<T, U>(matchingGroups);
- } else {
- if (matchingGroups.size() == 0) {
- return new ArrayList<Map<T, U>>(0).iterator();
- }
- Map.Entry<Set<T>, Set<U>> entry = matchingGroups.entrySet().iterator().next();
- return new MappingIterator<T,U>(entry.getKey(),
- entry.getValue());
- }
- }
-
- private GroupMappingIterator(Map<Set<T>, Set<U>> matchingGroups) {
- if (matchingGroups.size() == 0) {
- throw new IllegalArgumentException("matchingGroups must not be empty");
- }
- restMap = new HashMap<Set<T>, Set<U>>();
- boolean first = true;
- for (Map.Entry<Set<T>, Set<U>> entry : matchingGroups.entrySet()) {
- if (first) {
- firstPartIter = new MappingIterator<T,U>(entry.getKey(),
- entry.getValue());
- first = false;
- } else {
- restMap.put(entry.getKey(), entry.getValue());
- }
- }
- currentRestPartIter = create(restMap);
- currentFirstPart = firstPartIter.next();
- }
-
- @Override
- public boolean hasNext() {
- return firstPartIter.hasNext() || currentRestPartIter.hasNext();
- }
-
- @Override
- public Map<T, U> next() {
- Map<T, U> restPart;
- if (currentRestPartIter.hasNext()) {
- restPart = currentRestPartIter.next();
- } else {
- if (firstPartIter.hasNext()) {
- currentFirstPart = firstPartIter.next();
- currentRestPartIter = create(restMap);
- restPart = currentRestPartIter.next();
- } else {
- throw new NoSuchElementException();
- }
- }
- Map<T, U> result = new HashMap<T, U>(restPart);
- result.putAll(currentFirstPart);
- return result;
- }
-
- @Override
- public void remove() {
- throw new UnsupportedOperationException("Not supported.");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/HashMatching.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/HashMatching.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/HashMatching.java
deleted file mode 100644
index 7b3d540..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/HashMatching.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.clerezza.rdf.core.impl.graphmatching;
-
-
-import org.apache.clerezza.rdf.core.impl.graphmatching.collections.IntHashMap;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.BlankNodeOrIri;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.Iri;
-import org.apache.clerezza.rdf.core.impl.TripleImpl;
-import org.apache.clerezza.rdf.core.impl.graphmatching.collections.IntIterator;
-
-/**
- *
- * @author reto
- */
-public class HashMatching {
-
- private Map<BlankNode, BlankNode> matchings = new HashMap<BlankNode, BlankNode>();
- private Map<Set<BlankNode>, Set<BlankNode>> matchingGroups;
-
- /**
- * tc1 and tc2 will be modified: the triples containing no unmatched bnode
- * will be removed
- *
- * @param tc1
- * @param tc2
- * @throws GraphNotIsomorphicException
- */
- HashMatching(Graph tc1, Graph tc2) throws GraphNotIsomorphicException {
- int foundMatchings = 0;
- int foundMatchingGroups = 0;
- Map<BlankNode, Integer> bNodeHashMap = new HashMap<BlankNode, Integer>();
- while (true) {
- bNodeHashMap = matchByHashes(tc1, tc2, bNodeHashMap);
- if (bNodeHashMap == null) {
- throw new GraphNotIsomorphicException();
- }
- if (matchings.size() == foundMatchings) {
- if (!(matchingGroups.size() > foundMatchingGroups)) {
- break;
- }
- }
- foundMatchings = matchings.size();
- foundMatchingGroups = matchingGroups.size();
- }
- }
-
- /**
- *
- * @return a map containing set of which each bnodes mappes one of the other set
- */
- public Map<Set<BlankNode>, Set<BlankNode>> getMatchingGroups() {
- return matchingGroups;
- }
-
- public Map<BlankNode, BlankNode> getMatchings() {
- return matchings;
- }
-
-
- private static IntHashMap<Set<BlankNode>> getHashNodes(Map<BlankNode,
- Set<Property>> bNodePropMap, Map<BlankNode, Integer> bNodeHashMap) {
- IntHashMap<Set<BlankNode>> result = new IntHashMap<Set<BlankNode>>();
- for (Map.Entry<BlankNode, Set<Property>> entry : bNodePropMap.entrySet()) {
- int hash = computeHash(entry.getValue(), bNodeHashMap);
- Set<BlankNode> bNodeSet = result.get(hash);
- if (bNodeSet == null) {
- bNodeSet = new HashSet<BlankNode>();
- result.put(hash,bNodeSet);
- }
- bNodeSet.add(entry.getKey());
- }
- return result;
- }
- /*
- * returns a Map from bnodes to hash that can be used for future
- * refinements, this could be separate for each ImmutableGraph.
- *
- * triples no longer containing an unmatched bnodes ae removed.
- *
- * Note that the matched node are not guaranteed to be equals, but only to
- * be the correct if the graphs are isomorphic.
- */
- private Map<BlankNode, Integer> matchByHashes(Graph g1, Graph g2,
- Map<BlankNode, Integer> bNodeHashMap) {
- Map<BlankNode, Set<Property>> bNodePropMap1 = getBNodePropMap(g1);
- Map<BlankNode, Set<Property>> bNodePropMap2 = getBNodePropMap(g2);
- IntHashMap<Set<BlankNode>> hashNodeMap1 = getHashNodes(bNodePropMap1, bNodeHashMap);
- IntHashMap<Set<BlankNode>> hashNodeMap2 = getHashNodes(bNodePropMap2, bNodeHashMap);
- if (!hashNodeMap1.keySet().equals(hashNodeMap2.keySet())) {
- return null;
- }
-
- matchingGroups = new HashMap<Set<BlankNode>, Set<BlankNode>>();
- IntIterator hashIter = hashNodeMap1.keySet().intIterator();
- while (hashIter.hasNext()) {
- int hash = hashIter.next();
- Set<BlankNode> nodes1 = hashNodeMap1.get(hash);
- Set<BlankNode> nodes2 = hashNodeMap2.get(hash);
- if (nodes1.size() != nodes2.size()) {
- return null;
- }
- if (nodes1.size() != 1) {
- matchingGroups.put(nodes1, nodes2);
- continue;
- }
- final BlankNode bNode1 = nodes1.iterator().next();
- final BlankNode bNode2 = nodes2.iterator().next();
- matchings.put(bNode1,bNode2);
- //in the graphs replace node occurences with grounded node,
- BlankNodeOrIri mappedNode = new MappedNode(bNode1, bNode2);
- replaceNode(g1,bNode1, mappedNode);
- replaceNode(g2, bNode2, mappedNode);
- //remove grounded triples
- if (!Utils.removeGrounded(g1,g2)) {
- return null;
- }
- }
- Map<BlankNode, Integer> result = new HashMap<BlankNode, Integer>();
- addInverted(result, hashNodeMap1);
- addInverted(result, hashNodeMap2);
- return result;
- }
- private static int computeHash(Set<Property> propertySet, Map<BlankNode, Integer> bNodeHashMap) {
- int result = 0;
- for (Property property : propertySet) {
- result += property.hashCode(bNodeHashMap);
- }
- return result;
- }
- private static Map<BlankNode, Set<Property>> getBNodePropMap(Graph g) {
- Set<BlankNode> bNodes = Utils.getBNodes(g);
- Map<BlankNode, Set<Property>> result = new HashMap<BlankNode, Set<Property>>();
- for (BlankNode bNode : bNodes) {
- result.put(bNode, getProperties(bNode, g));
- }
- return result;
- }
- private static Set<Property> getProperties(BlankNode bNode, Graph g) {
- Set<Property> result = new HashSet<Property>();
- Iterator<Triple> ti = g.filter(bNode, null, null);
- while (ti.hasNext()) {
- Triple triple = ti.next();
- result.add(new ForwardProperty(triple.getPredicate(), triple.getObject()));
- }
- ti = g.filter(null, null, bNode);
- while (ti.hasNext()) {
- Triple triple = ti.next();
- result.add(new BackwardProperty(triple.getSubject(), triple.getPredicate()));
- }
- return result;
- }
- private static int nodeHash(RdfTerm resource, Map<BlankNode, Integer> bNodeHashMap) {
- if (resource instanceof BlankNode) {
- Integer mapValue = bNodeHashMap.get((BlankNode)resource);
- if (mapValue == null) {
- return 0;
- } else {
- return mapValue;
- }
- } else {
- return resource.hashCode();
- }
- }
- private static void replaceNode(Graph graph, BlankNode bNode, BlankNodeOrIri replacementNode) {
- Set<Triple> triplesToRemove = new HashSet<Triple>();
- for (Triple triple : graph) {
- Triple replacementTriple = getReplacement(triple, bNode, replacementNode);
- if (replacementTriple != null) {
- triplesToRemove.add(triple);
- graph.add(replacementTriple);
- }
- }
- graph.removeAll(triplesToRemove);
- }
- private static Triple getReplacement(Triple triple, BlankNode bNode, BlankNodeOrIri replacementNode) {
- if (triple.getSubject().equals(bNode)) {
- if (triple.getObject().equals(bNode)) {
- return new TripleImpl(replacementNode, triple.getPredicate(), replacementNode);
- } else {
- return new TripleImpl(replacementNode, triple.getPredicate(), triple.getObject());
- }
- } else {
- if (triple.getObject().equals(bNode)) {
- return new TripleImpl(triple.getSubject(), triple.getPredicate(), replacementNode);
- } else {
- return null;
- }
- }
- }
- private static void addInverted(Map<BlankNode, Integer> result, IntHashMap<Set<BlankNode>> hashNodeMap) {
- for (int hash : hashNodeMap.keySet()) {
- Set<BlankNode> bNodes = hashNodeMap.get(hash);
- for (BlankNode bNode : bNodes) {
- result.put(bNode, hash);
- }
- }
- }
-
- private static class BackwardProperty implements Property {
- private BlankNodeOrIri subject;
- private Iri predicate;
-
- public BackwardProperty(BlankNodeOrIri subject, Iri predicate) {
- this.subject = subject;
- this.predicate = predicate;
- }
-
- @Override
- public int hashCode(Map<BlankNode, Integer> bNodeHashMap) {
- return 0xFF ^ predicate.hashCode() ^ nodeHash(subject, bNodeHashMap);
- }
-
- }
- private static class ForwardProperty implements Property {
- private Iri predicate;
- private RdfTerm object;
-
- public ForwardProperty(Iri predicate, RdfTerm object) {
- this.predicate = predicate;
- this.object = object;
- }
-
- @Override
- public int hashCode(Map<BlankNode, Integer> bNodeHashMap) {
- return predicate.hashCode() ^ nodeHash(object, bNodeHashMap);
- }
- }
- private static class MappedNode implements BlankNodeOrIri {
- private BlankNode bNode1, bNode2;
-
- public MappedNode(BlankNode bNode1, BlankNode bNode2) {
- this.bNode1 = bNode1;
- this.bNode2 = bNode2;
- }
-
- }
- private static interface Property {
- public int hashCode(Map<BlankNode, Integer> bNodeHashMap);
- }
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/MappingIterator.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/MappingIterator.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/MappingIterator.java
deleted file mode 100644
index 3027f27..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/MappingIterator.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package org.apache.clerezza.rdf.core.impl.graphmatching;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * An iterator over all possible mapping beetween the elemnets of two sets of
- * the same size, each mapping maps each element from set1 to a disctinct one of
- * set2.
- *
- *
- *
- * @author reto
- */
-class MappingIterator<T,U> implements Iterator<Map<T, U>> {
-
- private List<T> list1;
- private Iterator<List<U>> permutationList2Iterator;
-
-
- public MappingIterator(Set<T> set1, Set<U> set2) {
- if (set1.size() != set2.size()) {
- throw new IllegalArgumentException();
- }
- this.list1 = new ArrayList<T>(set1);
- permutationList2Iterator = new PermutationIterator<U>(
- new ArrayList<U>(set2));
- }
-
- @Override
- public boolean hasNext() {
- return permutationList2Iterator.hasNext();
- }
-
- @Override
- public Map<T, U> next() {
- List<U> list2 = permutationList2Iterator.next();
- Map<T, U> result = new HashMap<T, U>(list1.size());
- for (int i = 0; i < list1.size(); i++) {
- result.put(list1.get(i), list2.get(i));
- }
- return result;
- }
-
- @Override
- public void remove() {
- throw new UnsupportedOperationException("Not supported.");
- }
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/PermutationIterator.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/PermutationIterator.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/PermutationIterator.java
deleted file mode 100644
index 92dffca..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/PermutationIterator.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.clerezza.rdf.core.impl.graphmatching;
-
-
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-/**
- *
- * An Iterator over all permuations of a list.
- *
- * @author reto
- */
-class PermutationIterator<T> implements Iterator<List<T>> {
-
- private Iterator<List<T>> restIterator;
- private List<T> list;
- private List<T> next;
- int posInList = 0; //the position of the last element of next returned list
- //with list, this is the one excluded from restIterator
-
- PermutationIterator(List<T> list) {
- this.list = Collections.unmodifiableList(list);
- if (list.size() > 1) {
- createRestList();
- }
- prepareNext();
- }
-
- @Override
- public boolean hasNext() {
- return next != null;
- }
-
- @Override
- public List<T> next() {
- List<T> result = next;
- if (result == null) {
- throw new NoSuchElementException();
- }
- prepareNext();
- return result;
- }
-
- @Override
- public void remove() {
- throw new UnsupportedOperationException("Not supported");
- }
-
- private void createRestList() {
- List<T> restList = new ArrayList<T>(list);
- restList.remove(posInList);
- restIterator = new PermutationIterator<T>(restList);
- }
-
- private void prepareNext() {
- next = getNext();
-
- }
- private List<T> getNext() {
- if (list.size() == 0) {
- return null;
- }
- if (list.size() == 1) {
- if (posInList++ == 0) {
- return new ArrayList<T>(list);
- } else {
- return null;
- }
- } else {
- if (!restIterator.hasNext()) {
- if (posInList < (list.size()-1)) {
- posInList++;
- createRestList();
- } else {
- return null;
- }
- }
- List<T> result = restIterator.next();
- result.add(list.get(posInList));
- return result;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/Utils.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/Utils.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/Utils.java
deleted file mode 100644
index f8400fd..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/Utils.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package org.apache.clerezza.rdf.core.impl.graphmatching;
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.Triple;
-
-public class Utils {
-
- static Set<BlankNode> getBNodes(Collection<Triple> s) {
- Set<BlankNode> result = new HashSet<BlankNode>();
- for (Triple triple : s) {
- if (triple.getSubject() instanceof BlankNode) {
- result.add((BlankNode) triple.getSubject());
- }
- if (triple.getObject() instanceof BlankNode) {
- result.add((BlankNode) triple.getObject());
- }
- }
- return result;
- }
-
- /**
- * removes the common grounded triples from s1 and s2. returns false if
- * a grounded triple is not in both sets, true otherwise
- */
- static boolean removeGrounded(Collection<Triple> s1, Collection<Triple> s2) {
- Iterator<Triple> triplesIter = s1.iterator();
- while (triplesIter.hasNext()) {
- Triple triple = triplesIter.next();
- if (!isGrounded(triple)) {
- continue;
- }
- if (!s2.remove(triple)) {
- return false;
- }
- triplesIter.remove();
- }
- //for efficiency we might skip this (redefine method)
- for (Triple triple : s2) {
- if (isGrounded(triple)) {
- return false;
- }
- }
- return true;
- }
-
- private static boolean isGrounded(Triple triple) {
- if (triple.getSubject() instanceof BlankNode) {
- return false;
- }
- if (triple.getObject() instanceof BlankNode) {
- return false;
- }
- return true;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntHashMap.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntHashMap.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntHashMap.java
deleted file mode 100644
index 474627e..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntHashMap.java
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
- * Copyright 2002-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * Note: originally released under the GNU LGPL v2.1,
- * but rereleased by the original author under the ASF license (above).
- */
-
-package org.apache.clerezza.rdf.core.impl.graphmatching.collections;
-
-
-
-/**
- * <p>A hash map that uses primitive ints for the key rather than objects.</p>
- *
- * <p>Note that this class is for internal optimization purposes only, and may
- * not be supported in future releases of Jakarta Commons Lang. Utilities of
- * this sort may be included in future releases of Jakarta Commons Collections.</p>
- *
- * @author Justin Couch
- * @author Alex Chaffee (alex@apache.org)
- * @author Stephen Colebourne
- * @since 2.0
- * @version $Revision: 1.2 $
- * @see java.util.HashMap
- */
-public class IntHashMap<T> {
-
-
- private IntSet keySet = new IntHashSet();
-
- /**
- * The hash table data.
- */
- private transient Entry<T> table[];
-
- /**
- * The total number of entries in the hash table.
- */
- private transient int count;
-
- /**
- * The table is rehashed when its size exceeds this threshold. (The
- * value of this field is (int)(capacity * loadFactor).)
- *
- * @serial
- */
- private int threshold;
-
- /**
- * The load factor for the hashtable.
- *
- * @serial
- */
- private float loadFactor;
-
- /**
- * <p>Innerclass that acts as a datastructure to create a new entry in the
- * table.</p>
- */
- private static class Entry<T> {
- int hash;
- int key;
- T value;
- Entry<T> next;
-
- /**
- * <p>Create a new entry with the given values.</p>
- *
- * @param hash The code used to hash the object with
- * @param key The key used to enter this in the table
- * @param value The value for this key
- * @param next A reference to the next entry in the table
- */
- protected Entry(int hash, int key, T value, Entry<T> next) {
- this.hash = hash;
- this.key = key;
- this.value = value;
- this.next = next;
- }
- }
-
- /**
- * <p>Constructs a new, empty hashtable with a default capacity and load
- * factor, which is <code>20</code> and <code>0.75</code> respectively.</p>
- */
- public IntHashMap() {
- this(20, 0.75f);
- }
-
- /**
- * <p>Constructs a new, empty hashtable with the specified initial capacity
- * and default load factor, which is <code>0.75</code>.</p>
- *
- * @param initialCapacity the initial capacity of the hashtable.
- * @throws IllegalArgumentException if the initial capacity is less
- * than zero.
- */
- public IntHashMap(int initialCapacity) {
- this(initialCapacity, 0.75f);
- }
-
- /**
- * <p>Constructs a new, empty hashtable with the specified initial
- * capacity and the specified load factor.</p>
- *
- * @param initialCapacity the initial capacity of the hashtable.
- * @param loadFactor the load factor of the hashtable.
- * @throws IllegalArgumentException if the initial capacity is less
- * than zero, or if the load factor is nonpositive.
- */
- public IntHashMap(int initialCapacity, float loadFactor) {
- super();
- if (initialCapacity < 0) {
- throw new IllegalArgumentException("Illegal Capacity: " + initialCapacity);
- }
- if (loadFactor <= 0) {
- throw new IllegalArgumentException("Illegal Load: " + loadFactor);
- }
- if (initialCapacity == 0) {
- initialCapacity = 1;
- }
-
- this.loadFactor = loadFactor;
- table = new Entry[initialCapacity];
- threshold = (int) (initialCapacity * loadFactor);
- }
-
- /**
- * <p>Returns the number of keys in this hashtable.</p>
- *
- * @return the number of keys in this hashtable.
- */
- public int size() {
- return count;
- }
-
- /**
- * <p>Tests if this hashtable maps no keys to values.</p>
- *
- * @return <code>true</code> if this hashtable maps no keys to values;
- * <code>false</code> otherwise.
- */
- public boolean isEmpty() {
- return count == 0;
- }
-
- /**
- * <p>Tests if some key maps into the specified value in this hashtable.
- * This operation is more expensive than the <code>containsKey</code>
- * method.</p>
- *
- * <p>Note that this method is identical in functionality to containsValue,
- * (which is part of the Map interface in the collections framework).</p>
- *
- * @param value a value to search for.
- * @return <code>true</code> if and only if some key maps to the
- * <code>value</code> argument in this hashtable as
- * determined by the <tt>equals</tt> method;
- * <code>false</code> otherwise.
- * @throws NullPointerException if the value is <code>null</code>.
- * @see #containsKey(int)
- * @see #containsValue(Object)
- * @see java.util.Map
- */
- public boolean contains(Object value) {
- if (value == null) {
- throw new NullPointerException();
- }
-
- Entry tab[] = table;
- for (int i = tab.length; i-- > 0;) {
- for (Entry e = tab[i]; e != null; e = e.next) {
- if (e.value.equals(value)) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * <p>Returns <code>true</code> if this HashMap maps one or more keys
- * to this value.</p>
- *
- * <p>Note that this method is identical in functionality to contains
- * (which predates the Map interface).</p>
- *
- * @param value value whose presence in this HashMap is to be tested.
- * @see java.util.Map
- * @since JDK1.2
- */
- public boolean containsValue(Object value) {
- return contains(value);
- }
-
- /**
- * <p>Tests if the specified object is a key in this hashtable.</p>
- *
- * @param key possible key.
- * @return <code>true</code> if and only if the specified object is a
- * key in this hashtable, as determined by the <tt>equals</tt>
- * method; <code>false</code> otherwise.
- * @see #contains(Object)
- */
- public boolean containsKey(int key) {
- Entry tab[] = table;
- int hash = key;
- int index = (hash & 0x7FFFFFFF) % tab.length;
- for (Entry e = tab[index]; e != null; e = e.next) {
- if (e.hash == hash) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * <p>Returns the value to which the specified key is mapped in this map.</p>
- *
- * @param key a key in the hashtable.
- * @return the value to which the key is mapped in this hashtable;
- * <code>null</code> if the key is not mapped to any value in
- * this hashtable.
- * @see #put(int, Object)
- */
- public T get(int key) {
- Entry<T> tab[] = table;
- int hash = key;
- int index = (hash & 0x7FFFFFFF) % tab.length;
- for (Entry<T> e = tab[index]; e != null; e = e.next) {
- if (e.hash == hash) {
- return e.value;
- }
- }
- return null;
- }
-
- /**
- * <p>Increases the capacity of and internally reorganizes this
- * hashtable, in order to accommodate and access its entries more
- * efficiently.</p>
- *
- * <p>This method is called automatically when the number of keys
- * in the hashtable exceeds this hashtable's capacity and load
- * factor.</p>
- */
- protected void rehash() {
- int oldCapacity = table.length;
- Entry<T> oldMap[] = table;
-
- int newCapacity = oldCapacity * 2 + 1;
- Entry<T> newMap[] = new Entry[newCapacity];
-
- threshold = (int) (newCapacity * loadFactor);
- table = newMap;
-
- for (int i = oldCapacity; i-- > 0;) {
- for (Entry<T> old = oldMap[i]; old != null;) {
- Entry<T> e = old;
- old = old.next;
-
- int index = (e.hash & 0x7FFFFFFF) % newCapacity;
- e.next = newMap[index];
- newMap[index] = e;
- }
- }
- }
-
- /**
- * <p>Maps the specified <code>key</code> to the specified
- * <code>value</code> in this hashtable. The key cannot be
- * <code>null</code>. </p>
- *
- * <p>The value can be retrieved by calling the <code>get</code> method
- * with a key that is equal to the original key.</p>
- *
- * @param key the hashtable key.
- * @param value the value.
- * @return the previous value of the specified key in this hashtable,
- * or <code>null</code> if it did not have one.
- * @throws NullPointerException if the key is <code>null</code>.
- * @see #get(int)
- */
- public Object put(int key, T value) {
- keySet.add(key);
- // Makes sure the key is not already in the hashtable.
- Entry<T> tab[] = table;
- int hash = key;
- int index = (hash & 0x7FFFFFFF) % tab.length;
- for (Entry<T> e = tab[index]; e != null; e = e.next) {
- if (e.hash == hash) {
- T old = e.value;
- e.value = value;
- return old;
- }
- }
-
- if (count >= threshold) {
- // Rehash the table if the threshold is exceeded
- rehash();
-
- tab = table;
- index = (hash & 0x7FFFFFFF) % tab.length;
- }
-
- // Creates the new entry.
- Entry<T> e = new Entry<T>(hash, key, value, tab[index]);
- tab[index] = e;
- count++;
- return null;
- }
-
- /**
- * <p>Removes the key (and its corresponding value) from this
- * hashtable.</p>
- *
- * <p>This method does nothing if the key is not present in the
- * hashtable.</p>
- *
- * @param key the key that needs to be removed.
- * @return the value to which the key had been mapped in this hashtable,
- * or <code>null</code> if the key did not have a mapping.
- */
- /*public Object remove(int key) {
- Entry tab[] = table;
- int hash = key;
- int index = (hash & 0x7FFFFFFF) % tab.length;
- for (Entry e = tab[index], prev = null; e != null; prev = e, e = e.next) {
- if (e.hash == hash) {
- if (prev != null) {
- prev.next = e.next;
- } else {
- tab[index] = e.next;
- }
- count--;
- Object oldValue = e.value;
- e.value = null;
- return oldValue;
- }
- }
- return null;
- }*/
-
- /**
- * <p>Clears this hashtable so that it contains no keys.</p>
- */
- public synchronized void clear() {
- keySet.clear();
- Entry tab[] = table;
- for (int index = tab.length; --index >= 0;) {
- tab[index] = null;
- }
- count = 0;
- }
-
- public IntSet keySet() {
- return keySet;
- }
-
-
-
-}
-
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntHashSet.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntHashSet.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntHashSet.java
deleted file mode 100644
index 00e8517..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntHashSet.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2002-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.clerezza.rdf.core.impl.graphmatching.collections;
-
-import java.util.HashSet;
-import java.util.Iterator;
-
-/**
- * This is currently just a placeholder implementation based onm HashSet<Integer>
- * an efficient implementation is to store the primitives directly.
- *
- * @author reto
- */
-public class IntHashSet extends HashSet<Integer> implements IntSet {
-
- @Override
- public IntIterator intIterator() {
- final Iterator<Integer> base = iterator();
- return new IntIterator() {
-
- @Override
- public int nextInt() {
- return base.next();
- }
-
- @Override
- public boolean hasNext() {
- return base.hasNext();
- }
-
- @Override
- public Integer next() {
- return base.next();
- }
-
- @Override
- public void remove() {
- base.remove();
- }
- };
- }
-
- @Override
- public void add(int i) {
- super.add((Integer)i);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntIterator.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntIterator.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntIterator.java
deleted file mode 100644
index a2f189a..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntIterator.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2002-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.clerezza.rdf.core.impl.graphmatching.collections;
-
-import java.util.Iterator;
-
-
-/**
- * An iterator allowing to iterate over ints, Iterator<Integer> is extended for
- * compatibility, however accessing nextInt allows faster implementations.
- *
- * @author reto
- */
-public interface IntIterator extends Iterator<Integer> {
- public int nextInt();
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntSet.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntSet.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntSet.java
deleted file mode 100644
index 115f15d..0000000
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/graphmatching/collections/IntSet.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2002-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.clerezza.rdf.core.impl.graphmatching.collections;
-
-import java.util.Set;
-
-/**
- * A IntSet allows directly adding primitive ints to a set, Set<Integer> is
- * extended, but accessingt he respective methods is less efficient.
- *
- * @author reto
- */
-public interface IntSet extends Set<Integer> {
- /**
- *
- * @return an iterator over the primitive int
- */
- public IntIterator intIterator();
-
- public void add(int i);
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedGraphWrapper.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedGraphWrapper.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedGraphWrapper.java
index 97547c0..bde1f16 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedGraphWrapper.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/util/PrivilegedGraphWrapper.java
@@ -22,7 +22,8 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Collection;
import java.util.Iterator;
-import org.apache.clerezza.rdf.core.impl.SimpleImmutableGraph;
+import java.util.concurrent.locks.ReadWriteLock;
+import org.apache.commons.rdf.impl.utils.simple.SimpleImmutableGraph;
import org.apache.commons.rdf.BlankNodeOrIri;
import org.apache.commons.rdf.RdfTerm;
import org.apache.commons.rdf.Triple;
@@ -204,18 +205,8 @@ public class PrivilegedGraphWrapper implements Graph {
}
@Override
- public void addGraphListener(GraphListener listener, FilterTriple filter, long delay) {
- graph.addGraphListener(listener, filter, delay);
- }
-
- @Override
- public void addGraphListener(GraphListener listener, FilterTriple filter) {
- graph.addGraphListener(listener, filter);
- }
-
- @Override
- public void removeGraphListener(GraphListener listener) {
- graph.removeGraphListener(listener);
+ public ReadWriteLock getLock() {
+ return graph.getLock();
}
private static class PriviledgedTripleIterator implements Iterator<Triple> {