CLEREZZA-1026: Reformat codes in api.impl
diff --git a/api.impl/pom.xml b/api.impl/pom.xml
index 34f63ec..326b7e4 100644
--- a/api.impl/pom.xml
+++ b/api.impl/pom.xml
@@ -1,32 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
+ 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
- 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
- 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.
-
+ 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.
-->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>org.apache.clerezza</groupId>
<artifactId>clerezza</artifactId>
+ <groupId>org.apache.clerezza</groupId>
<version>8-SNAPSHOT</version>
- <relativePath />
+ <relativePath>../parent/pom.xml</relativePath>
</parent>
+ <modelVersion>4.0.0</modelVersion>
<artifactId>api.impl</artifactId>
<packaging>bundle</packaging>
@@ -39,15 +38,14 @@
<system>jira</system>
<url>http://issues.apache.org/jira/browse/CLEREZZA</url>
</issueManagement>
-
- <inceptionYear>2015</inceptionYear>
+
<scm>
<connection>scm:git:https://git-wip-us.apache.org/repos/asf/clerezza.git</connection>
<developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/clerezza.git</developerConnection>
<url>https://git-wip-us.apache.org/repos/asf/clerezza.git</url>
- <tag>HEAD</tag>
- </scm>
-
+ <tag>HEAD</tag>
+ </scm>
+
<build>
<plugins>
<plugin>
@@ -56,14 +54,13 @@
<extensions>true</extensions>
<configuration>
<instructions>
- <Export-Package>org.apache.clerezza.api.impl.*</Export-Package>
+ <Export-Package>${project.groupId}.${project.artifactId}.*</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
-
<dependencies>
<dependency>
<groupId>org.apache.clerezza</groupId>
@@ -76,5 +73,4 @@
<scope>test</scope>
</dependency>
</dependencies>
-
</project>
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/TripleImpl.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/TripleImpl.java
index 1f67d39..2848028 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/TripleImpl.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/TripleImpl.java
@@ -1,30 +1,28 @@
/*
- * 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
+ * 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.
+ * 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.api.impl;
import org.apache.clerezza.api.BlankNodeOrIRI;
+import org.apache.clerezza.api.IRI;
import org.apache.clerezza.api.RDFTerm;
import org.apache.clerezza.api.Triple;
-import org.apache.clerezza.api.IRI;
/**
- *
* @author reto
*/
public class TripleImpl implements Triple {
@@ -36,10 +34,10 @@
/**
* 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>.
+ * @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) {
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/debug/ReadLockDebug.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/debug/ReadLockDebug.java
index f826dee..1f63319 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/debug/ReadLockDebug.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/debug/ReadLockDebug.java
@@ -1,20 +1,19 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.debug;
@@ -24,7 +23,6 @@
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
/**
- *
* @author mir
*/
public class ReadLockDebug extends ReadLock {
@@ -33,6 +31,7 @@
StackTraceElement[] stackTrace;
ReadLock readLock;
+
public ReadLockDebug(ReentrantReadWriteLockTracker lock) {
super(lock);
this.lock = lock;
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/debug/ReentrantReadWriteLockTracker.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/debug/ReentrantReadWriteLockTracker.java
index 94e8a6c..70073cb 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/debug/ReentrantReadWriteLockTracker.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/debug/ReentrantReadWriteLockTracker.java
@@ -1,20 +1,19 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.debug;
@@ -26,7 +25,6 @@
import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
- *
* @author mir
*/
public class ReentrantReadWriteLockTracker extends ReentrantReadWriteLock {
@@ -34,6 +32,7 @@
private Set<ReadLockDebug> lockedReadLocks = Collections.synchronizedSet(new HashSet<ReadLockDebug>());
private final WriteLockDebug writeLock = new WriteLockDebug(this);
+
@Override
protected Thread getOwner() {
return super.getOwner();
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/debug/WriteLockDebug.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/debug/WriteLockDebug.java
index 82301a3..f0d567e 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/debug/WriteLockDebug.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/debug/WriteLockDebug.java
@@ -1,20 +1,19 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.debug;
@@ -24,7 +23,6 @@
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
/**
- *
* @author mir
*/
public class WriteLockDebug extends WriteLock {
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/AbstractGraph.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/AbstractGraph.java
index b4e996e..f03626f 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/AbstractGraph.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/AbstractGraph.java
@@ -1,39 +1,32 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.graph;
+import org.apache.clerezza.api.*;
+import org.apache.clerezza.api.impl.debug.ReentrantReadWriteLockTracker;
+
import java.util.AbstractCollection;
import java.util.Collection;
import java.util.Iterator;
-
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-import org.apache.clerezza.api.Graph;
-import org.apache.clerezza.api.IRI;
-import org.apache.clerezza.api.BlankNodeOrIRI;
-import org.apache.clerezza.api.RDFTerm;
-import org.apache.clerezza.api.Triple;
-import org.apache.clerezza.api.ImmutableGraph;
-import org.apache.clerezza.api.impl.debug.ReentrantReadWriteLockTracker;
-
/**
* An abstract implementation of <code>Graph</code> implementing
* <code>iterator</code> and <code>contains</code> calling <code>filter</code>.
@@ -43,7 +36,6 @@
public abstract class AbstractGraph extends AbstractCollection<Triple>
implements Graph {
-
private static final String DEBUG_MODE = "rdfLocksDebugging";
private final ReadWriteLock lock;
@@ -67,7 +59,7 @@
readLock = lock.readLock();
writeLock = lock.writeLock();
}
-
+
public AbstractGraph(final ReadWriteLock lock) {
this.lock = lock;
readLock = lock.readLock();
@@ -88,7 +80,7 @@
readLock.unlock();
}
}
-
+
public ImmutableGraph performGetImmutableGraph() {
return new SimpleImmutableGraph(this);
}
@@ -234,7 +226,7 @@
}
}
-
+
@Override
public boolean equals(Object obj) {
/*if (obj == null) {
@@ -302,5 +294,5 @@
return super.add(e);
}
-
+
}
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/AbstractImmutableGraph.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/AbstractImmutableGraph.java
index a9c35b6..d8fab05 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/AbstractImmutableGraph.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/AbstractImmutableGraph.java
@@ -1,45 +1,43 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.graph;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.apache.clerezza.api.impl.graphmatching.GraphMatcher;
import org.apache.clerezza.api.BlankNode;
import org.apache.clerezza.api.ImmutableGraph;
import org.apache.clerezza.api.RDFTerm;
import org.apache.clerezza.api.Triple;
+import org.apache.clerezza.api.impl.graphmatching.GraphMatcher;
+
+import java.util.Collection;
+import java.util.Iterator;
/**
- * <code>AbstractGraph</code> is an abstract implementation of <code>ImmutableGraph</code>
+ * <code>AbstractGraph</code> is an abstract implementation of <code>ImmutableGraph</code>
* implementing the <code>equals</code> and the <code>hashCode</code> methods.
- *
+ *
* @author reto
- *
*/
public abstract class AbstractImmutableGraph extends AbstractGraph
implements ImmutableGraph {
public final synchronized int hashCode() {
int result = 0;
- for (Iterator<Triple> iter = iterator(); iter.hasNext();) {
+ for (Iterator<Triple> iter = iterator(); iter.hasNext(); ) {
result += getBlankNodeBlindHash(iter.next());
}
return result;
@@ -89,8 +87,8 @@
public void clear() {
throw new UnsupportedOperationException("Graphs are not mutable, use Graph");
}
-
-
+
+
@Override
public ImmutableGraph getImmutableGraph() {
return this;
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/DelayedNotificator.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/DelayedNotificator.java
index a3512e2..1eee4ea 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/DelayedNotificator.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/DelayedNotificator.java
@@ -1,40 +1,37 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.graph;
+import org.apache.clerezza.api.event.GraphEvent;
+import org.apache.clerezza.api.event.GraphListener;
+
import java.lang.ref.WeakReference;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
-import org.apache.clerezza.api.event.GraphEvent;
-import org.apache.clerezza.api.event.GraphListener;
-
-
/**
- *
* @author reto
*/
class DelayedNotificator {
private static final Logger log = Logger.getLogger(DelayedNotificator.class.getName());
- private static Timer timer = new Timer("Event delivery timer",true);
+ private static Timer timer = new Timer("Event delivery timer", true);
static class ListenerHolder {
@@ -79,7 +76,7 @@
}
}
}
-
+
private final Map<GraphListener, ListenerHolder> map = Collections.synchronizedMap(
new WeakHashMap<GraphListener, ListenerHolder>());
@@ -100,6 +97,7 @@
/**
* if the listenerRef has not been registered as delayed listenerRef te events is
* forwarded synchroneously
+ *
* @param event
*/
void sendEventToListener(GraphListener listener, GraphEvent event) {
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/LockingIterator.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/LockingIterator.java
index 4db0d85..150b491 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/LockingIterator.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/LockingIterator.java
@@ -1,31 +1,32 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.graph;
+import org.apache.clerezza.api.Triple;
+
import java.util.Iterator;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
-import org.apache.clerezza.api.Triple;
/**
* Wrapps an iterator<Triple> reading entering a read-lock on every invocation
* of hasNext and next
+ *
* @author reto
*/
class LockingIterator implements Iterator<Triple> {
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/PrivilegedGraphWrapper.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/PrivilegedGraphWrapper.java
index ce682b0..8a911a5 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/PrivilegedGraphWrapper.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/PrivilegedGraphWrapper.java
@@ -1,20 +1,19 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.graph;
@@ -28,7 +27,7 @@
/**
* Calls the methods of the wrapped <code>Graph</code> as privileged
- * code, because they may need permissions like writing to disk or accessing
+ * code, because they may need permissions like writing to disk or accessing
* network.
*
* @author mir
@@ -43,7 +42,7 @@
@Override
public Iterator<Triple> filter(final BlankNodeOrIRI subject, final IRI predicate,
- final RDFTerm object) {
+ final RDFTerm object) {
return AccessController.doPrivileged(new PrivilegedAction<Iterator<Triple>>() {
@Override
@@ -244,8 +243,7 @@
});
}
}
-
-
+
@Override
public ImmutableGraph getImmutableGraph() {
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/PrivilegedImmuatbleGraphWrapper.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/PrivilegedImmuatbleGraphWrapper.java
index f9367ac..1a73b8c 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/PrivilegedImmuatbleGraphWrapper.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/PrivilegedImmuatbleGraphWrapper.java
@@ -1,20 +1,19 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.graph;
@@ -22,9 +21,9 @@
/**
* Calls the methods of the wrapped <code>ImmutableGraph</code> as privileged
- * code, because they may need permissions like writing to disk or accessing
+ * code, because they may need permissions like writing to disk or accessing
* network.
- *
+ *
* @author mir
*/
public class PrivilegedImmuatbleGraphWrapper extends PrivilegedGraphWrapper
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/ReadOnlyException.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/ReadOnlyException.java
index ea5456f..2b7a933 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/ReadOnlyException.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/ReadOnlyException.java
@@ -1,28 +1,27 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.graph;
import java.security.AccessControlException;
/**
- * is thrown on an attempt to add or remove triples to a
- * read-only mutable ImmutableGraph
+ * is thrown on an attempt to add or remove triples to a
+ * read-only mutable ImmutableGraph
*
* @author tsuy
*/
@@ -32,16 +31,15 @@
/**
* creates an exception indicating that the mutable ImmutableGraph is read-only
- *
+ *
* @param action
*/
public ReadOnlyException(String action) {
- super("read only mutable ImmutableGraph, not allowed to "+action);
+ super("read only mutable ImmutableGraph, not allowed to " + action);
this.action = action;
}
/**
- *
* @return the name of the action
*/
public String getAction() {
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/SimpleGraph.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/SimpleGraph.java
index 0209c28..922c81d 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/SimpleGraph.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/SimpleGraph.java
@@ -1,20 +1,19 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.graph;
@@ -43,6 +42,7 @@
public SimpleIterator(Iterator<Triple> listIter) {
this.listIter = listIter;
}
+
private Triple currentNext;
@Override
@@ -56,14 +56,14 @@
checkValidity();
currentNext = listIter.next();
return currentNext;
- }
+ }
@Override
public void remove() {
checkValidity();
listIter.remove();
- triples.remove(currentNext);
- invalidateIterators(this);
+ triples.remove(currentNext);
+ invalidateIterators(this);
}
private void checkValidity() throws ConcurrentModificationException {
@@ -75,11 +75,11 @@
private void invalidate() {
isValid = false;
}
- }
-
+ }
+
private final Set<SoftReference<SimpleIterator>> iterators =
Collections.synchronizedSet(new HashSet<SoftReference<SimpleIterator>>());
-
+
/**
* Creates an empty SimpleGraph
*/
@@ -88,9 +88,9 @@
}
/**
- * Creates a SimpleGraph using the passed iterator, the iterator
+ * Creates a SimpleGraph using the passed iterator, the iterator
* is consumed before the constructor returns
- *
+ *
* @param iterator
*/
public SimpleGraph(Iterator<Triple> iterator) {
@@ -102,9 +102,9 @@
}
/**
- * Creates a SimpleGraph for the specified set of triples,
+ * Creates a SimpleGraph for the specified set of triples,
* subsequent modification of baseSet do affect the created instance.
- *
+ *
* @param baseSet
*/
public SimpleGraph(Set<Triple> baseSet) {
@@ -166,13 +166,13 @@
}
return modified;
}
-
+
private void invalidateIterators(SimpleIterator caller) {
if (!checkConcurrency) {
return;
}
Set<SoftReference> oldReferences = new HashSet<SoftReference>();
- synchronized(iterators) {
+ synchronized (iterators) {
for (SoftReference<SimpleGraph.SimpleIterator> softReference : iterators) {
SimpleIterator simpleIterator = softReference.get();
if (simpleIterator == null) {
@@ -197,8 +197,8 @@
public void setCheckConcurrency(boolean bool) {
checkConcurrency = bool;
}
-
-
+
+
@Override
public ImmutableGraph getImmutableGraph() {
return new SimpleImmutableGraph(this);
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/SimpleImmutableGraph.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/SimpleImmutableGraph.java
index 46b95ad..a0840f5 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/SimpleImmutableGraph.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/SimpleImmutableGraph.java
@@ -1,42 +1,36 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.graph;
+import org.apache.clerezza.api.*;
+
import java.util.Iterator;
-import org.apache.clerezza.api.BlankNodeOrIRI;
-import org.apache.clerezza.api.RDFTerm;
-import org.apache.clerezza.api.Triple;
-import org.apache.clerezza.api.Graph;
-import org.apache.clerezza.api.IRI;
-
/**
- *
* @author reto
*/
public class SimpleImmutableGraph extends AbstractImmutableGraph {
private Graph graph;
-
+
/**
* Creates a ImmutableGraph with the triples in Graph
- *
+ *
* @param Graph the collection of triples this ImmutableGraph shall consist of
*/
public SimpleImmutableGraph(Graph Graph) {
@@ -45,13 +39,13 @@
/**
* Creates a ImmutableGraph with the triples in Graph.
- *
+ * <p>
* This construction allows to specify if the Graph might change
* in future. If GraphWillNeverChange is set to true it will
* assume that the collection never changes, in this case the collection
* isn't copied making things more efficient.
*
- * @param Graph the collection of triples this ImmutableGraph shall consist of
+ * @param Graph the collection of triples this ImmutableGraph shall consist of
* @param GraphWillNeverChange true if the caller promises Graph will never change
*/
public SimpleImmutableGraph(Graph Graph, boolean GraphWillNeverChange) {
@@ -61,7 +55,7 @@
this.graph = Graph;
}
}
-
+
public SimpleImmutableGraph(Iterator<Triple> tripleIter) {
this.graph = new SimpleGraph(tripleIter);
}
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/SimpleMGraph.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/SimpleMGraph.java
index 94cd03a..cc5cd74 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/SimpleMGraph.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/SimpleMGraph.java
@@ -1,34 +1,32 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.graph;
+import org.apache.clerezza.api.Graph;
+import org.apache.clerezza.api.Triple;
+
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
-import org.apache.clerezza.api.Graph;
-import org.apache.clerezza.api.Triple;
-
/**
- *
- * @deprecated Use SimpleGraph
* @author reto
+ * @deprecated Use SimpleGraph
*/
@Deprecated
public class SimpleMGraph extends SimpleGraph implements Graph {
@@ -52,5 +50,3 @@
}
}
-
-
\ No newline at end of file
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/WatchableGraphWrapper.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/WatchableGraphWrapper.java
index c86156d..f82a48a 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/WatchableGraphWrapper.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/WatchableGraphWrapper.java
@@ -1,17 +1,21 @@
/*
* Copyright 2015 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
+ * 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
+ * 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.
+ * 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.api.impl.graph;
@@ -23,18 +27,17 @@
import java.util.concurrent.locks.ReadWriteLock;
/**
- *
* @author developer
*/
public class WatchableGraphWrapper implements WatchableGraph {
-
+
final Graph wrapped;
public WatchableGraphWrapper(Graph wrapped) {
this.wrapped = wrapped;
}
-
-
+
+
//all listeners
private final Set<ListenerConfiguration> listenerConfigs = Collections.synchronizedSet(
new HashSet<ListenerConfiguration>());
@@ -91,10 +94,10 @@
}
/**
- * A subclass of <code>AbstractGraph</code> should override
+ * A subclass of <code>AbstractGraph</code> should override
* this method instead of <code>add</code> for Graph event support to be
* added.
- *
+ *
* @param e The triple to be added to the triple collection
* @return
*/
@@ -115,7 +118,7 @@
@Override
public boolean removeAll(Collection<?> c) {
boolean modified = false;
- for (Iterator<? extends Object> it = c.iterator(); it.hasNext();) {
+ for (Iterator<? extends Object> it = c.iterator(); it.hasNext(); ) {
Object object = it.next();
if (remove(object)) {
modified = true;
@@ -125,10 +128,10 @@
}
/**
- * A subclass of <code>AbstractGraph</code> should override
+ * A subclass of <code>AbstractGraph</code> should override
* this method instead of <code>remove</code> for ImmutableGraph event support to be
* added.
- *
+ *
* @param o The triple to be removed from the triple collection
* @return
*/
@@ -147,12 +150,12 @@
* Dispatches a <code>GraphEvent</code> to all registered listeners for which
* the specified <code>Triple</code> matches the <code>FilterTriple</code>s
* of the listeners.
- *
+ *
* @param triple The Triple that was modified
- * @param type The type of modification
+ * @param type The type of modification
*/
protected void dispatchEvent(GraphEvent event) {
- synchronized(listenerConfigs) {
+ synchronized (listenerConfigs) {
Iterator<ListenerConfiguration> iter = listenerConfigs.iterator();
while (iter.hasNext()) {
ListenerConfiguration config = iter.next();
@@ -175,7 +178,7 @@
@Override
public void addGraphListener(GraphListener listener, FilterTriple filter,
- long delay) {
+ long delay) {
listenerConfigs.add(new ListenerConfiguration(listener, filter));
if (delay > 0) {
delayedNotificator.addDelayedListener(listener, delay);
@@ -184,7 +187,7 @@
@Override
public void removeGraphListener(GraphListener listener) {
- synchronized(listenerConfigs) {
+ synchronized (listenerConfigs) {
Iterator<ListenerConfiguration> iter = listenerConfigs.iterator();
while (iter.hasNext()) {
ListenerConfiguration listenerConfig = iter.next();
@@ -272,5 +275,5 @@
return filter;
}
}
-
+
}
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/WriteBlockedGraph.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/WriteBlockedGraph.java
index 71fce87..cb80c3d 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/WriteBlockedGraph.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/graph/WriteBlockedGraph.java
@@ -1,20 +1,19 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.graph;
@@ -24,10 +23,9 @@
import java.util.Iterator;
/**
- *
- * 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>
+ * 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>
* and throws exceptions when add or remove methods are called.
*
* @author tsuy
@@ -50,7 +48,7 @@
protected Iterator<Triple> performFilter(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
final Iterator<Triple> baseIter = triples.filter(subject, predicate, object);
return new Iterator<Triple>() {
-
+
@Override
public boolean hasNext() {
return baseIter.hasNext();
@@ -66,7 +64,7 @@
throw new ReadOnlyException("remove");
}
-
+
};
}
@@ -94,7 +92,7 @@
public boolean removeAll(Collection<?> c) {
throw new ReadOnlyException("remove all");
}
-
+
@Override
public boolean retainAll(Collection<?> c) {
throw new ReadOnlyException("retain all");
@@ -104,7 +102,7 @@
public Iterator iterator() {
return filter(null, null, null);
}
-
+
@Override
public ImmutableGraph getImmutableGraph() {
return this.triples.getImmutableGraph();
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/GraphMatcher.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/GraphMatcher.java
index 754e05d..3061279 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/GraphMatcher.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/GraphMatcher.java
@@ -1,46 +1,38 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.graphmatching;
-
+import org.apache.clerezza.api.*;
+import org.apache.clerezza.api.impl.TripleImpl;
+import org.apache.clerezza.api.impl.graph.SimpleMGraph;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
-import org.apache.clerezza.api.BlankNode;
-import org.apache.clerezza.api.BlankNodeOrIRI;
-import org.apache.clerezza.api.Graph;
-import org.apache.clerezza.api.RDFTerm;
-import org.apache.clerezza.api.Triple;
-import org.apache.clerezza.api.impl.TripleImpl;
-import org.apache.clerezza.api.impl.graph.SimpleMGraph;
/**
* @author reto
- *
*/
public class GraphMatcher {
-
private final static Logger log = Logger.getLogger(GraphMatcher.class.getName());
/**
@@ -53,7 +45,7 @@
* nodes, a bnode in g1 is not a vraiable that may match any node, but must
* match a bnode in g2.
* <p/>
- *
+ * <p>
* On the algorithm:<br/>
* - In a first step it checked if every grounded triple in g1 matches one
* in g2<br/>
@@ -65,7 +57,7 @@
* 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
@@ -73,7 +65,7 @@
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)) {
+ if (!Utils.removeGrounded(g1, g2)) {
return null;
}
final HashMatching hashMatching;
@@ -99,10 +91,10 @@
}
private static Map<BlankNode, BlankNode> trialAndErrorMatching(Graph g1, Graph g2,
- Map<Set<BlankNode>, Set<BlankNode>> matchingGroups) {
+ Map<Set<BlankNode>, Set<BlankNode>> matchingGroups) {
if (log.isLoggable(Level.FINE)) {
- Set<BlankNode> bn1 = Utils.getBNodes(g1);
- log.log(Level.FINE,"doing trial and error matching for {0}"+" bnodes, "+"in graphs of size: {1}.", new Object[]{bn1.size(), g1.size()});
+ Set<BlankNode> bn1 = Utils.getBNodes(g1);
+ log.log(Level.FINE, "doing trial and error matching for {0}" + " bnodes, " + "in graphs of size: {1}.", new Object[]{bn1.size(), g1.size()});
}
Iterator<Map<BlankNode, BlankNode>> mappingIter
= GroupMappingIterator.create(matchingGroups);
@@ -128,13 +120,11 @@
final BlankNodeOrIRI oSubject = triple.getSubject();
BlankNodeOrIRI subject = oSubject instanceof BlankNode ?
- map.get((BlankNode)oSubject) : oSubject;
+ map.get((BlankNode) oSubject) : oSubject;
RDFTerm oObject = triple.getObject();
RDFTerm object = oObject instanceof BlankNode ?
- map.get((BlankNode)oObject) : oObject;
+ map.get((BlankNode) oObject) : oObject;
return new TripleImpl(subject, triple.getPredicate(), object);
}
-
-
}
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/GraphNotIsomorphicException.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/GraphNotIsomorphicException.java
index 3137098..b40d608 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/GraphNotIsomorphicException.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/GraphNotIsomorphicException.java
@@ -1,26 +1,23 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.graphmatching;
/**
- *
* @author reto
*/
class GraphNotIsomorphicException extends Exception {
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/GroupMappingIterator.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/GroupMappingIterator.java
index 1d271bf..2e58fd3 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/GroupMappingIterator.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/GroupMappingIterator.java
@@ -1,28 +1,23 @@
/*
- * 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.
+ * 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.api.impl.graphmatching;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Set;
+import java.util.*;
/**
* Iterates over all mappings from each element of every Set<T> to each
@@ -30,14 +25,14 @@
*
* @author reto
*/
-class GroupMappingIterator<T,U> implements Iterator<Map<T, U>> {
+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) {
+ 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 {
@@ -45,8 +40,8 @@
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());
+ return new MappingIterator<T, U>(entry.getKey(),
+ entry.getValue());
}
}
@@ -58,7 +53,7 @@
boolean first = true;
for (Map.Entry<Set<T>, Set<U>> entry : matchingGroups.entrySet()) {
if (first) {
- firstPartIter = new MappingIterator<T,U>(entry.getKey(),
+ firstPartIter = new MappingIterator<T, U>(entry.getKey(),
entry.getValue());
first = false;
} else {
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/HashMatching.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/HashMatching.java
index 13b8436..95ba4e8 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/HashMatching.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/HashMatching.java
@@ -1,43 +1,31 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.graphmatching;
-
-import org.apache.clerezza.api.BlankNode;
-import org.apache.clerezza.api.Graph;
-import org.apache.clerezza.api.IRI;
+import org.apache.clerezza.api.*;
import org.apache.clerezza.api.impl.TripleImpl;
-import org.apache.clerezza.api.impl.graphmatching.collections.IntIterator;
import org.apache.clerezza.api.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.clerezza.api.impl.graphmatching.collections.IntIterator;
-import org.apache.clerezza.api.BlankNodeOrIRI;
-import org.apache.clerezza.api.RDFTerm;
-import org.apache.clerezza.api.Triple;
+import java.util.*;
/**
- *
* @author reto
*/
public class HashMatching {
@@ -73,7 +61,6 @@
}
/**
- *
* @return a map containing set of which each bnodes mappes one of the other set
*/
public Map<Set<BlankNode>, Set<BlankNode>> getMatchingGroups() {
@@ -84,7 +71,7 @@
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>>();
@@ -93,12 +80,13 @@
Set<BlankNode> bNodeSet = result.get(hash);
if (bNodeSet == null) {
bNodeSet = new HashSet<BlankNode>();
- result.put(hash,bNodeSet);
+ 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.
@@ -109,9 +97,9 @@
* 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);
+ 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())) {
@@ -133,13 +121,13 @@
}
final BlankNode bNode1 = nodes1.iterator().next();
final BlankNode bNode2 = nodes2.iterator().next();
- matchings.put(bNode1,bNode2);
+ matchings.put(bNode1, bNode2);
//in the graphs replace node occurences with grounded node,
BlankNodeOrIRI mappedNode = new MappedNode(bNode1, bNode2);
- replaceNode(g1,bNode1, mappedNode);
+ replaceNode(g1, bNode1, mappedNode);
replaceNode(g2, bNode2, mappedNode);
//remove grounded triples
- if (!Utils.removeGrounded(g1,g2)) {
+ if (!Utils.removeGrounded(g1, g2)) {
return null;
}
}
@@ -148,6 +136,7 @@
addInverted(result, hashNodeMap2);
return result;
}
+
private static int computeHash(Set<Property> propertySet, Map<BlankNode, Integer> bNodeHashMap) {
int result = 0;
for (Property property : propertySet) {
@@ -155,6 +144,7 @@
}
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>>();
@@ -163,6 +153,7 @@
}
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);
@@ -177,9 +168,10 @@
}
return result;
}
+
private static int nodeHash(RDFTerm resource, Map<BlankNode, Integer> bNodeHashMap) {
if (resource instanceof BlankNode) {
- Integer mapValue = bNodeHashMap.get((BlankNode)resource);
+ Integer mapValue = bNodeHashMap.get((BlankNode) resource);
if (mapValue == null) {
return 0;
} else {
@@ -189,6 +181,7 @@
return resource.hashCode();
}
}
+
private static void replaceNode(Graph graph, BlankNode bNode, BlankNodeOrIRI replacementNode) {
Set<Triple> triplesToRemove = new HashSet<Triple>();
for (Triple triple : graph) {
@@ -200,6 +193,7 @@
}
graph.removeAll(triplesToRemove);
}
+
private static Triple getReplacement(Triple triple, BlankNode bNode, BlankNodeOrIRI replacementNode) {
if (triple.getSubject().equals(bNode)) {
if (triple.getObject().equals(bNode)) {
@@ -215,6 +209,7 @@
}
}
}
+
private static void addInverted(Map<BlankNode, Integer> result, IntHashMap<Set<BlankNode>> hashNodeMap) {
for (int hash : hashNodeMap.keySet()) {
Set<BlankNode> bNodes = hashNodeMap.get(hash);
@@ -223,45 +218,48 @@
}
}
}
-
+
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);
+ 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);
}
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/MappingIterator.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/MappingIterator.java
index 6c5c245..22dd267 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/MappingIterator.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/MappingIterator.java
@@ -1,42 +1,32 @@
-package org.apache.clerezza.api.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
+ * 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.
+ * 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.api.impl.graphmatching;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
/**
* 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>> {
+class MappingIterator<T, U> implements Iterator<Map<T, U>> {
private List<T> list1;
private Iterator<List<U>> permutationList2Iterator;
@@ -72,5 +62,4 @@
}
-
}
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/PermutationIterator.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/PermutationIterator.java
index 74e9eff..70a0554 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/PermutationIterator.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/PermutationIterator.java
@@ -1,34 +1,25 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.graphmatching;
-
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
+import java.util.*;
/**
- *
* An Iterator over all permuations of a list.
*
* @author reto
@@ -77,8 +68,9 @@
private void prepareNext() {
next = getNext();
-
+
}
+
private List<T> getNext() {
if (list.size() == 0) {
return null;
@@ -91,7 +83,7 @@
}
} else {
if (!restIterator.hasNext()) {
- if (posInList < (list.size()-1)) {
+ if (posInList < (list.size() - 1)) {
posInList++;
createRestList();
} else {
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/Utils.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/Utils.java
index 30f0f0d..fb89099 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/Utils.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/Utils.java
@@ -1,34 +1,30 @@
-package org.apache.clerezza.api.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
+ * 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.
- *
-*/
+ * 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.api.impl.graphmatching;
+import org.apache.clerezza.api.BlankNode;
+import org.apache.clerezza.api.Triple;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
-import org.apache.clerezza.api.BlankNode;
-import org.apache.clerezza.api.Triple;
-
public class Utils {
static Set<BlankNode> getBNodes(Collection<Triple> s) {
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/collections/IntHashMap.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/collections/IntHashMap.java
index ac117af..f4ca392 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/collections/IntHashMap.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/collections/IntHashMap.java
@@ -1,17 +1,21 @@
/*
* 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.
+ * 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.
*/
/*
@@ -21,11 +25,9 @@
package org.apache.clerezza.api.impl.graphmatching.collections;
-
-
/**
* <p>A hash map that uses primitive ints for the key rather than objects.</p>
- *
+ * <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>
@@ -33,9 +35,9 @@
* @author Justin Couch
* @author Alex Chaffee (alex@apache.org)
* @author Stephen Colebourne
- * @since 2.0
* @version $Revision: 1.2 $
* @see java.util.HashMap
+ * @since 2.0
*/
public class IntHashMap<T> {
@@ -80,10 +82,10 @@
/**
* <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 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
+ * @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;
@@ -105,9 +107,9 @@
* <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.
+ * @param initialCapacity the initial capacity of the hashtable.
* @throws IllegalArgumentException if the initial capacity is less
- * than zero.
+ * than zero.
*/
public IntHashMap(int initialCapacity) {
this(initialCapacity, 0.75f);
@@ -118,9 +120,9 @@
* 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.
+ * @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();
@@ -142,7 +144,7 @@
/**
* <p>Returns the number of keys in this hashtable.</p>
*
- * @return the number of keys in this hashtable.
+ * @return the number of keys in this hashtable.
*/
public int size() {
return count;
@@ -151,8 +153,8 @@
/**
* <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.
+ * @return <code>true</code> if this hashtable maps no keys to values;
+ * <code>false</code> otherwise.
*/
public boolean isEmpty() {
return count == 0;
@@ -162,19 +164,19 @@
* <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>
* <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
+ * @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) {
@@ -182,7 +184,7 @@
}
Entry tab[] = table;
- for (int i = tab.length; i-- > 0;) {
+ for (int i = tab.length; i-- > 0; ) {
for (Entry e = tab[i]; e != null; e = e.next) {
if (e.value.equals(value)) {
return true;
@@ -195,12 +197,12 @@
/**
* <p>Returns <code>true</code> if this HashMap maps one or more keys
* to this value.</p>
- *
+ * <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
+ * @see java.util.Map
* @since JDK1.2
*/
public boolean containsValue(Object value) {
@@ -210,10 +212,10 @@
/**
* <p>Tests if the specified object is a key in this hashtable.</p>
*
- * @param key possible key.
+ * @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.
+ * key in this hashtable, as determined by the <tt>equals</tt>
+ * method; <code>false</code> otherwise.
* @see #contains(Object)
*/
public boolean containsKey(int key) {
@@ -231,11 +233,11 @@
/**
* <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)
+ * @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;
@@ -253,7 +255,7 @@
* <p>Increases the capacity of and internally reorganizes this
* hashtable, in order to accommodate and access its entries more
* efficiently.</p>
- *
+ * <p>
* <p>This method is called automatically when the number of keys
* in the hashtable exceeds this hashtable's capacity and load
* factor.</p>
@@ -268,8 +270,8 @@
threshold = (int) (newCapacity * loadFactor);
table = newMap;
- for (int i = oldCapacity; i-- > 0;) {
- for (Entry<T> old = oldMap[i]; old != null;) {
+ for (int i = oldCapacity; i-- > 0; ) {
+ for (Entry<T> old = oldMap[i]; old != null; ) {
Entry<T> e = old;
old = old.next;
@@ -284,19 +286,19 @@
* <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>
* <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.
+ * @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)
+ * 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);
+ keySet.add(key);
// Makes sure the key is not already in the hashtable.
Entry<T> tab[] = table;
int hash = key;
@@ -332,7 +334,7 @@
* hashtable.</p>
*
* @param key the key that needs to be removed.
- * @return the value to which the key had been mapped in this hashtable,
+ * @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) {
@@ -359,19 +361,18 @@
* <p>Clears this hashtable so that it contains no keys.</p>
*/
public synchronized void clear() {
- keySet.clear();
+ keySet.clear();
Entry tab[] = table;
- for (int index = tab.length; --index >= 0;) {
+ for (int index = tab.length; --index >= 0; ) {
tab[index] = null;
}
count = 0;
}
-
+
public IntSet keySet() {
- return keySet;
+ return keySet;
}
-
-
-
+
+
}
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/collections/IntHashSet.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/collections/IntHashSet.java
index 4d6b13b..e85518e 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/collections/IntHashSet.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/collections/IntHashSet.java
@@ -1,17 +1,21 @@
/*
* 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
+ * 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
+ * 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.
+ * 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.api.impl.graphmatching.collections;
@@ -56,7 +60,7 @@
@Override
public void add(int i) {
- super.add((Integer)i);
+ super.add((Integer) i);
}
}
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/collections/IntIterator.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/collections/IntIterator.java
index 3bf38ed..9f0309d 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/collections/IntIterator.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/collections/IntIterator.java
@@ -1,24 +1,27 @@
/*
* 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
+ * 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
+ * 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.
+ * 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.api.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.
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/collections/IntSet.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/collections/IntSet.java
index 8bd64c1..d6042e6 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/collections/IntSet.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/graphmatching/collections/IntSet.java
@@ -1,17 +1,21 @@
/*
* 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
+ * 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
+ * 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.
+ * 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.api.impl.graphmatching.collections;
@@ -19,17 +23,16 @@
import java.util.Set;
/**
- * A IntSet allows directly adding primitive ints to a set, Set<Integer> is
+ * 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);
}
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/AbstractLiteral.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/AbstractLiteral.java
index 8444813..4c0c385 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/AbstractLiteral.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/AbstractLiteral.java
@@ -1,24 +1,27 @@
/*
* Copyright 2015 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
+ * 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
+ * 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.
+ * 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.api.impl.literal;
import org.apache.clerezza.api.Literal;
/**
- *
* @author developer
*/
public abstract class AbstractLiteral implements Literal {
@@ -41,7 +44,7 @@
}
if (obj instanceof Literal) {
Literal other = (Literal) obj;
-
+
if (getLanguage() == null) {
if (other.getLanguage() != null) {
return false;
@@ -57,5 +60,5 @@
return false;
}
}
-
+
}
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/InvalidLiteralTypeException.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/InvalidLiteralTypeException.java
index f4665db..e4a1482 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/InvalidLiteralTypeException.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/InvalidLiteralTypeException.java
@@ -1,20 +1,19 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.literal;
@@ -26,15 +25,15 @@
* @author reto
*/
public class InvalidLiteralTypeException extends RuntimeException {
-
+
/**
- * Constructs the exception to be thrown when a literal cannot be
+ * Constructs the exception to be thrown when a literal cannot be
* converted to an instance of the specified class
*
- * @param javaType the <code>Class</code> to convert to
+ * @param javaType the <code>Class</code> to convert to
* @param literalType the literalType which can't be converted
*/
public InvalidLiteralTypeException(Class<?> javaType, IRI literalType) {
- super("Cannot create a "+javaType+" from a literal of type "+literalType);
+ super("Cannot create a " + javaType + " from a literal of type " + literalType);
}
}
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/LiteralFactory.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/LiteralFactory.java
index fc971bd..9bbbe76 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/LiteralFactory.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/LiteralFactory.java
@@ -1,20 +1,19 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.literal;
@@ -25,14 +24,14 @@
* vice versa. While the default implementation will provide literal objects
* storing the data's lexical form in memory, other implementations may
* create literal optimized for processing within the store.
- *
- * Note: this class uses the notion of "Convertor" (in the Exception naming),
+ * <p>
+ * Note: this class uses the notion of "Convertor" (in the Exception naming),
* but does not currently provide a mechanism to register such
* <code>Convertor</code>s. An implementation is said to provide
* <code>Convertor</code>s for the types it supports.
*
- * @since 0.3
* @author reto
+ * @since 0.3
*/
public abstract class LiteralFactory {
@@ -72,10 +71,10 @@
* Converts a literal to an instance of the specified class
*
* @param <T>
- * @param type the <code>Class</code> of the returned object
+ * @param type the <code>Class</code> of the returned object
* @param literal the literal to be converted
* @return a java object representing the value of the literal
- * @throws NoConvertorException thrown if <code>type</code> is unsupported
+ * @throws NoConvertorException thrown if <code>type</code> is unsupported
* @throws InvalidLiteralTypeException if the literal type doesn't match the requested java type
*/
public abstract <T> T createObject(Class<T> type, Literal literal)
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/LiteralImpl.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/LiteralImpl.java
index 7d86242..5c383ff 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/LiteralImpl.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/LiteralImpl.java
@@ -1,42 +1,40 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.literal;
-import java.io.Serializable;
-
import org.apache.clerezza.api.IRI;
import org.apache.clerezza.api.Language;
+import java.io.Serializable;
+
/**
- *
* @author reto
*/
-public class LiteralImpl extends AbstractLiteral implements Serializable {
+public class LiteralImpl extends AbstractLiteral implements Serializable {
private String lexicalForm;
private IRI dataType;
private int hashCode;
private Language language;
/**
- * @param lexicalForm
- * @param dataType
- * @param Language the language of this literal
+ * @param lexicalForm
+ * @param dataType
+ * @param Language the language of this literal
*/
public LiteralImpl(String lexicalForm, IRI dataType, Language language) {
this.lexicalForm = lexicalForm;
@@ -44,7 +42,7 @@
this.language = language;
this.hashCode = super.hashCode();
}
-
+
public IRI getDataType() {
return dataType;
}
@@ -61,7 +59,7 @@
public int hashCode() {
return hashCode;
}
-
+
@Override
public String toString() {
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/NoConvertorException.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/NoConvertorException.java
index a462394..7eeb4d5 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/NoConvertorException.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/NoConvertorException.java
@@ -1,20 +1,19 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.literal;
@@ -24,8 +23,8 @@
* This exception is thrown when no convertor is available to do a required
* java-object to literal or literal to java-object conversion.
*
- * @since 0.3
* @author reto
+ * @since 0.3
*/
public class NoConvertorException extends RuntimeException {
@@ -36,6 +35,6 @@
* @param type the type for which no convertor is available
*/
public NoConvertorException(Type type) {
- super("No convertor available for type "+type);
+ super("No convertor available for type " + type);
}
}
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/PlainLiteralImpl.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/PlainLiteralImpl.java
index aeef1ea..0eec686 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/PlainLiteralImpl.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/PlainLiteralImpl.java
@@ -1,31 +1,29 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.literal;
-import java.io.Serializable;
-
import org.apache.clerezza.api.IRI;
import org.apache.clerezza.api.Language;
import org.apache.clerezza.api.Literal;
+import java.io.Serializable;
+
/**
- *
* @author reto
*/
public class PlainLiteralImpl extends AbstractLiteral implements Literal, Serializable {
@@ -74,6 +72,7 @@
public IRI getDataType() {
return dataType;
}
+
private final IRI dataType;
private static final IRI XSD_STRING = new IRI("http://www.w3.org/2001/XMLSchema#string");
private static final IRI RDF_LANG_STRING = new IRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString");
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/SimpleLiteralFactory.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/SimpleLiteralFactory.java
index 9bbbb1b..7b01843 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/SimpleLiteralFactory.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/SimpleLiteralFactory.java
@@ -1,20 +1,19 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.literal;
@@ -31,7 +30,7 @@
/**
* An implementation of literal factory currently supporting only
* byte[]/base64Binary and Java.util.Date/date
- *
+ *
* @author reto
*/
@@ -43,7 +42,7 @@
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>();
@@ -51,7 +50,7 @@
final static Class<? extends byte[]> byteArrayType;
static {
- Collections.addAll(decimalTypes, xsdInteger, xsdInt, xsdByte, xsdShort, xsdLong );
+ Collections.addAll(decimalTypes, xsdInteger, xsdInt, xsdByte, xsdShort, xsdLong);
byte[] byteArray = new byte[0];
byteArrayType = byteArray.getClass();
@@ -67,22 +66,23 @@
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 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);
+ return new IRI(XSD + name);
}
private static interface TypeConverter<T> {
Literal createLiteral(T value);
- T createObject(Literal literal);
+
+ T createObject(Literal literal);
}
- private static class ByteArrayConverter implements TypeConverter<byte[]> {
+ private static class ByteArrayConverter implements TypeConverter<byte[]> {
- private static final IRI base64Uri =xsd("base64Binary");
+ private static final IRI base64Uri = xsd("base64Binary");
@Override
public Literal createLiteral(byte[] value) {
@@ -97,11 +97,12 @@
return (byte[]) Base64.decode(literal.getLexicalForm());
}
-
+
}
+
private static class DateConverter implements TypeConverter<Date> {
- private static final IRI dateTimeUri =xsd("dateTime");
+ private static final IRI dateTimeUri = xsd("dateTime");
private static final DateFormat DATE_FORMAT = new W3CDateFormat();
@Override
@@ -126,7 +127,7 @@
private static class BooleanConverter implements TypeConverter<Boolean> {
- private static final IRI booleanUri =xsd("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);
@@ -149,7 +150,7 @@
private static class StringConverter implements TypeConverter<String> {
- private static final IRI stringUri =xsd("string");
+ private static final IRI stringUri = xsd("string");
@Override
public Literal createLiteral(String value) {
@@ -184,7 +185,6 @@
private static class LongConverter implements TypeConverter<Long> {
-
@Override
public Literal createLiteral(Long value) {
@@ -216,9 +216,8 @@
return Float.valueOf(literal.getLexicalForm());
}
}
-
- private static class DoubleConverter implements TypeConverter<Double> {
+ private static class DoubleConverter implements TypeConverter<Double> {
@Override
@@ -238,7 +237,6 @@
private static class BigIntegerConverter implements TypeConverter<BigInteger> {
-
@Override
public Literal createLiteral(BigInteger value) {
return new TypedLiteralImpl(value.toString(), xsdInteger);
@@ -252,9 +250,8 @@
return new BigInteger(literal.getLexicalForm());
}
}
-
- private static class UriRefConverter implements TypeConverter<IRI> {
+ private static class UriRefConverter implements TypeConverter<IRI> {
@Override
@@ -279,14 +276,13 @@
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")
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/TypedLiteralImpl.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/TypedLiteralImpl.java
index 8b029d2..0f7e3dd 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/TypedLiteralImpl.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/literal/TypedLiteralImpl.java
@@ -1,47 +1,45 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.literal;
-import java.io.Serializable;
-
import org.apache.clerezza.api.IRI;
import org.apache.clerezza.api.Language;
+import java.io.Serializable;
+
/**
- *
* @author reto
*/
-public class TypedLiteralImpl extends AbstractLiteral implements Serializable {
+public class TypedLiteralImpl extends AbstractLiteral implements Serializable {
private String lexicalForm;
private IRI dataType;
private int hashCode;
/**
- * @param lexicalForm
- * @param dataType
+ * @param lexicalForm
+ * @param dataType
*/
public TypedLiteralImpl(String lexicalForm, IRI dataType) {
this.lexicalForm = lexicalForm;
this.dataType = dataType;
this.hashCode = super.hashCode();
}
-
+
public IRI getDataType() {
return dataType;
}
@@ -58,7 +56,7 @@
public int hashCode() {
return hashCode;
}
-
+
@Override
public String toString() {
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/package-info.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/package-info.java
index 80652e5..a2c5f76 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/package-info.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/package-info.java
@@ -1,18 +1,18 @@
/*
* 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
+ * 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
+ * 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.
+ * 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.api.impl;
\ No newline at end of file
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/util/Base64.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/util/Base64.java
index 28607eb..f5b6dc3 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/util/Base64.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/util/Base64.java
@@ -2,28 +2,25 @@
* Taken from the book:
* Jonathan Knudsen, "Java Cryptography", O'Reilly Media, Inc., 1998
*/
-package org.apache.clerezza.api.impl.util;
/*
*
- * 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
+ * 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.
- *
-*/
-
+ * 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.api.impl.util;
public class Base64 {
diff --git a/api.impl/src/main/java/org/apache/clerezza/api/impl/util/W3CDateFormat.java b/api.impl/src/main/java/org/apache/clerezza/api/impl/util/W3CDateFormat.java
index a337064..4921968 100644
--- a/api.impl/src/main/java/org/apache/clerezza/api/impl/util/W3CDateFormat.java
+++ b/api.impl/src/main/java/org/apache/clerezza/api/impl/util/W3CDateFormat.java
@@ -5,44 +5,37 @@
[See end of file]
$Id: W3CDateFormat.java,v 1.6 2007/05/07 18:45:22 rebach Exp $
*/
-package org.apache.clerezza.api.impl.util;
/*
*
- * 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
+ * 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.
- *
-*/
-
+ * 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.api.impl.util;
import java.text.DateFormat;
import java.text.FieldPosition;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.SimpleTimeZone;
-import java.util.TimeZone;
+import java.util.*;
/**
* @author reto implements http://www.w3.org/TR/NOTE-datetime with the
- * limitation that it expects exactly a three digits decimal fraction of
- * seconds. if a time zone designator other than 'Z' is present it must
- * contain a column
+ * limitation that it expects exactly a three digits decimal fraction of
+ * seconds. if a time zone designator other than 'Z' is present it must
+ * contain a column
*/
public class W3CDateFormat extends DateFormat {
/**
@@ -72,17 +65,17 @@
/**
* @see java.text.DateFormat#format(java.util.Date, java.lang.StringBuffer,
- * java.text.FieldPosition)
+ * java.text.FieldPosition)
*/
@Override
public StringBuffer format(Date date, StringBuffer toAppendTo,
- FieldPosition fieldPosition) {
+ FieldPosition fieldPosition) {
final DateFormat dateFormat = (date.getTime() % 1000) == 0 ?
- dateFormatNoMillis : dateFormatWithMillis;
+ dateFormatNoMillis : dateFormatWithMillis;
String string = dateFormat.format(date);
if (string.endsWith("0000")) {
- StringBuffer result = new StringBuffer(string.substring(0, string.length()-5));
+ StringBuffer result = new StringBuffer(string.substring(0, string.length() - 5));
result.append('Z');
return result;
} else {
@@ -94,7 +87,7 @@
/**
* @see java.text.DateFormat#parse(java.lang.String,
- * java.text.ParsePosition)
+ * java.text.ParsePosition)
*/
public Date parse(String dateString, ParsePosition parsePos) {
@@ -136,7 +129,7 @@
//read decimal part, this is till there is a 'Z', a '+' or a '-'
char nextChar = dateString.charAt(position++);
while ((nextChar != 'Z') && (nextChar != '-') && (nextChar != '+')) {
- msecs += (nextChar - '0')*Math.pow(10, 3+startPos-position);
+ msecs += (nextChar - '0') * Math.pow(10, 3 + startPos - position);
nextChar = dateString.charAt(position++);
}
tzd1 = nextChar;
diff --git a/api.impl/src/test/java/org/apache/clerezza/api/impl/LanguageTest.java b/api.impl/src/test/java/org/apache/clerezza/api/impl/LanguageTest.java
index c50e41b..77c419a 100644
--- a/api.impl/src/test/java/org/apache/clerezza/api/impl/LanguageTest.java
+++ b/api.impl/src/test/java/org/apache/clerezza/api/impl/LanguageTest.java
@@ -1,35 +1,31 @@
/*
- * 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
+ * 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.
+ * 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.api.impl;
-
import org.apache.clerezza.api.Language;
import org.junit.Assert;
import org.junit.Test;
-
/**
- *
* @author reto
*/
public class LanguageTest {
-
+
@Test
public void languageEqualityTest() {
Language lang1 = new Language("DE");
@@ -39,7 +35,7 @@
Language lang3 = new Language("EN");
Assert.assertFalse(lang1.equals(lang3));
}
-
+
@Test
public void toStringTest() {
final String id = "de";
diff --git a/api.impl/src/test/java/org/apache/clerezza/api/impl/UriRefTest.java b/api.impl/src/test/java/org/apache/clerezza/api/impl/UriRefTest.java
index 5f924a8..8aefff6 100644
--- a/api.impl/src/test/java/org/apache/clerezza/api/impl/UriRefTest.java
+++ b/api.impl/src/test/java/org/apache/clerezza/api/impl/UriRefTest.java
@@ -1,37 +1,34 @@
/*
- * 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
+ * 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.
+ * 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.api.impl;
import org.apache.clerezza.api.IRI;
+import org.junit.Assert;
+import org.junit.Test;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
-import org.junit.Assert;
-import org.junit.Test;
-
/**
- *
* @author reto
*/
public class UriRefTest {
-
+
@Test
public void uriRefEqualityTest() throws UnsupportedEncodingException {
String uriRefString = "http://example.org/üöä";
@@ -41,12 +38,12 @@
IRI uriRef3 = new IRI(URLEncoder.encode(uriRefString, "utf-8"));
Assert.assertFalse(uriRef1.equals(uriRef3));
}
-
+
@Test
public void toStringTest() {
String uriRefString = "http://example.org/üöä";
IRI uriRef = new IRI(uriRefString);
- Assert.assertEquals("<"+uriRefString+">", uriRef.toString());
+ Assert.assertEquals("<" + uriRefString + ">", uriRef.toString());
}
}
diff --git a/api.impl/src/test/java/org/apache/clerezza/api/impl/graph/GraphTest.java b/api.impl/src/test/java/org/apache/clerezza/api/impl/graph/GraphTest.java
index 66ad861..66a3b3c 100644
--- a/api.impl/src/test/java/org/apache/clerezza/api/impl/graph/GraphTest.java
+++ b/api.impl/src/test/java/org/apache/clerezza/api/impl/graph/GraphTest.java
@@ -1,20 +1,19 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.graph;
@@ -27,8 +26,6 @@
import java.util.*;
-
-
/**
* A generic abstract test class, implementations overwrite this class,
* providing an implementation of the getEmptyGraph method.
@@ -55,7 +52,7 @@
private Triple trpl2 = new TripleImpl(uriRef1, uriRef2, uriRef1);
private Triple trpl3 = new TripleImpl(bnode2, uriRef3, literal2);
private Triple trpl4 = new TripleImpl(uriRef3, uriRef4, literal2);
-
+
/**
* Subclasses implement this method to provide implementation instances of
* Graph. This method may be called an arbitrary amount of time,
@@ -64,7 +61,7 @@
* @return an empty Graph of the implementation to be tested
*/
protected abstract Graph getEmptyGraph();
-
+
@Test
public void testAddCountAndGetTriples() {
Graph graph = getEmptyGraph();
@@ -77,7 +74,8 @@
Triple tripleGot = tripleIter.next();
Assert.assertEquals(triple1, tripleGot);
Assert.assertFalse(tripleIter.hasNext());
- BlankNode bnode = new BlankNode() {};
+ BlankNode bnode = new BlankNode() {
+ };
graph.add(new TripleImpl(bnode, uriRef1, uriRef3));
graph.add(new TripleImpl(bnode, uriRef1, uriRef4));
tripleIter = graph.filter(null, uriRef1, null);
@@ -106,7 +104,7 @@
Assert.assertFalse(tripleIter.hasNext());
Assert.assertEquals(retrievedTriple.getSubject(), retrievedTriple.getObject());
}
-
+
@Test
public void testRemoveAllTriples() {
Graph graph = getEmptyGraph();
@@ -122,7 +120,7 @@
public void testUseTypedLiterals() {
Graph graph = getEmptyGraph();
Assert.assertEquals(0, graph.size());
- Literal value = new TypedLiteralImpl("<elem>value</elem>",xmlLiteralType);
+ Literal value = new TypedLiteralImpl("<elem>value</elem>", xmlLiteralType);
final TripleImpl triple1 = new TripleImpl(uriRef1, uriRef2, value);
graph.add(triple1);
Iterator<Triple> tripleIter = graph.filter(uriRef1, uriRef2, null);
@@ -136,14 +134,14 @@
Graph graph = getEmptyGraph();
Assert.assertEquals(0, graph.size());
Language language = new Language("it");
- Literal value = new PlainLiteralImpl("<elem>value</elem>",language);
+ Literal value = new PlainLiteralImpl("<elem>value</elem>", language);
final TripleImpl triple1 = new TripleImpl(uriRef1, uriRef2, value);
graph.add(triple1);
Iterator<Triple> tripleIter = graph.filter(uriRef1, uriRef2, null);
Assert.assertTrue(tripleIter.hasNext());
RDFTerm gotValue = tripleIter.next().getObject();
Assert.assertEquals(value, gotValue);
- Assert.assertEquals(language, ((Literal)gotValue).getLanguage());
+ Assert.assertEquals(language, ((Literal) gotValue).getLanguage());
}
@Test
@@ -174,7 +172,7 @@
@Test
public void testAddSingleTriple() throws Exception {
Graph graph = getEmptyGraph();
- final Triple triple= createTriple(
+ final Triple triple = createTriple(
"http://example.org/ontology/Person",
"http://example.org/ontology/hasName",
"http://example.org/people/alice");
@@ -187,7 +185,7 @@
@Test
public void testAddSameTripleTwice() throws Exception {
Graph graph = getEmptyGraph();
- final Triple triple= createTriple(
+ final Triple triple = createTriple(
"http://example.org/ontology/Person",
"http://example.org/ontology/hasName",
"http://example.org/people/alice");
@@ -201,7 +199,7 @@
@Test
public void testRemoveSingleTriple() throws Exception {
Graph graph = getEmptyGraph();
- final Triple triple= createTriple(
+ final Triple triple = createTriple(
"http://example.org/ontology/Person",
"http://example.org/ontology/hasName",
"http://example.org/people/alice");
@@ -213,11 +211,11 @@
@Test
public void testRemoveSameTripleTwice() throws Exception {
Graph graph = getEmptyGraph();
- final Triple tripleAlice= createTriple(
+ final Triple tripleAlice = createTriple(
"http://example.org/ontology/Person",
"http://example.org/ontology/hasName",
"http://example.org/people/alice");
- final Triple tripleBob= createTriple(
+ final Triple tripleBob = createTriple(
"http://example.org/ontology/Person",
"http://example.org/ontology/hasName",
"http://example.org/people/bob");
@@ -246,7 +244,7 @@
@Test
public void testContainsIfContained() throws Exception {
Graph graph = getEmptyGraph();
- final Triple triple= createTriple(
+ final Triple triple = createTriple(
"http://example.org/ontology/Person",
"http://example.org/ontology/hasName",
"http://example.org/people/alice");
@@ -258,7 +256,7 @@
@Test
public void testContainsIfEmpty() throws Exception {
Graph graph = getEmptyGraph();
- final Triple triple= createTriple(
+ final Triple triple = createTriple(
"http://example.org/ontology/Person",
"http://example.org/ontology/hasName",
"http://example.org/people/alice");
@@ -269,11 +267,11 @@
@Test
public void testContainsIfNotContained() throws Exception {
Graph graph = getEmptyGraph();
- final Triple tripleAdd= createTriple(
+ final Triple tripleAdd = createTriple(
"http://example.org/ontology/Person",
"http://example.org/ontology/hasName",
"http://example.org/people/alice");
- final Triple tripleTest= createTriple(
+ final Triple tripleTest = createTriple(
"http://example.org/ontology/Person",
"http://example.org/ontology/hasName",
"http://example.org/people/bob");
@@ -293,14 +291,14 @@
@Test
public void testFilterSingleEntry() throws Exception {
Graph graph = getEmptyGraph();
- final Triple triple= createTriple(
+ final Triple triple = createTriple(
"http://example.org/ontology/Person",
"http://example.org/ontology/hasName",
"http://example.org/people/alice");
Assert.assertTrue(graph.add(triple));
Iterator<Triple> i = graph.filter(null, null, null);
- Collection<Triple> resultSet= toCollection(i);
+ Collection<Triple> resultSet = toCollection(i);
Assert.assertEquals(1, resultSet.size());
Assert.assertTrue(resultSet.contains(triple));
}
@@ -309,11 +307,11 @@
@Test
public void testFilterByObject() throws Exception {
Graph graph = getEmptyGraph();
- final Triple tripleAlice= createTriple(
+ final Triple tripleAlice = createTriple(
"http://example.org/ontology/Person",
"http://example.org/ontology/hasName",
"http://example.org/people/alice");
- final Triple tripleBob= createTriple(
+ final Triple tripleBob = createTriple(
"http://example.org/ontology/Person",
"http://example.org/ontology/hasName",
"http://example.org/people/bob");
@@ -326,219 +324,220 @@
// Find bob
iterator = graph.filter(null, null,
new IRI("http://example.org/people/bob"));
- resultSet= toCollection(iterator);
+ resultSet = toCollection(iterator);
Assert.assertEquals(1, resultSet.size());
Assert.assertTrue(resultSet.contains(tripleBob));
// Find alice
iterator = graph.filter(null, null,
new IRI("http://example.org/people/alice"));
- resultSet= toCollection(iterator);
+ resultSet = toCollection(iterator);
Assert.assertEquals(1, resultSet.size());
Assert.assertTrue(resultSet.contains(tripleAlice));
// Find both
iterator = graph.filter(null, null, null);
- resultSet= toCollection(iterator);
+ resultSet = toCollection(iterator);
Assert.assertEquals(2, resultSet.size());
Assert.assertTrue(resultSet.contains(tripleAlice));
Assert.assertTrue(resultSet.contains(tripleBob));
}
-/*
- @Test
- public void graphEventTestAddRemove() {
- Graph mGraph = getEmptyGraph();
- TestGraphListener listener = new TestGraphListener();
- mGraph.addGraphListener(listener, new FilterTriple(uriRef1, uriRef2, null));
- mGraph.addGraphListener(listener, new FilterTriple(bnode2, null, literal2));
- mGraph.addGraphListener(listener, new FilterTriple(null, uriRef4, literal2));
- mGraph.add(trpl1);
- Assert.assertNull(listener.getEvents());
- mGraph.add(trpl2);
- Assert.assertEquals(1, listener.getEvents().size());
- Assert.assertEquals(trpl2, listener.getEvents().get(0).getTriple());
- Assert.assertTrue(listener.getEvents().get(0) instanceof AddEvent);
- listener.resetEvents();
- mGraph.remove(trpl2);
- Assert.assertEquals(1, listener.getEvents().size());
- Assert.assertEquals(trpl2, listener.getEvents().get(0).getTriple());
- Assert.assertTrue(listener.getEvents().get(0) instanceof RemoveEvent);
- listener.resetEvents();
- mGraph.add(trpl3);
- Assert.assertEquals(1, listener.getEvents().size());
- Assert.assertEquals(trpl3, listener.getEvents().get(0).getTriple());
- Assert.assertTrue(listener.getEvents().get(0) instanceof AddEvent);
- listener.resetEvents();
- mGraph.remove(trpl4);
- Assert.assertNull(listener.getEvents());
- }
-
- @Test
- public void graphEventTestAddAllRemoveAll() {
- Graph mGraph = getEmptyGraph();
- TestGraphListener listener = new TestGraphListener();
- mGraph.addGraphListener(listener, new FilterTriple(uriRef1, uriRef2, null));
- mGraph.addGraphListener(listener, new FilterTriple(bnode2, null, literal2));
- mGraph.addGraphListener(listener, new FilterTriple(null, uriRef4, literal2));
- Graph triples = new SimpleGraph();
- triples.add(trpl1);
- triples.add(trpl2);
- triples.add(trpl3);
- triples.add(trpl4);
- mGraph.addAll(triples);
- List<GraphEvent> cumulatedEvents = listener.getCumulatedEvents();
- Set<Triple> cumulatedTriples = getCumulatedTriples(cumulatedEvents);
- Assert.assertEquals(3, cumulatedEvents.size());
- Assert.assertTrue(cumulatedEvents.get(0) instanceof AddEvent);
- Assert.assertTrue(cumulatedTriples.contains(trpl2));
- Assert.assertTrue(cumulatedTriples.contains(trpl3));
- Assert.assertTrue(cumulatedTriples.contains(trpl4));
- listener.resetCumulatedEvents();
- mGraph.removeAll(triples);
- cumulatedEvents = listener.getCumulatedEvents();
- cumulatedTriples = getCumulatedTriples(cumulatedEvents);
- Assert.assertEquals(3, cumulatedEvents.size());
- Assert.assertTrue(cumulatedEvents.get(0) instanceof RemoveEvent);
- Assert.assertTrue(cumulatedTriples.contains(trpl2));
- Assert.assertTrue(cumulatedTriples.contains(trpl3));
- Assert.assertTrue(cumulatedTriples.contains(trpl4));
- }
- @Test
- public void graphEventTestFilterRemove() {
- Graph mGraph = getEmptyGraph();
- TestGraphListener listener = new TestGraphListener();
- mGraph.addGraphListener(listener, new FilterTriple(uriRef1, uriRef2, null));
- mGraph.addGraphListener(listener, new FilterTriple(bnode2, null, literal2));
- mGraph.addGraphListener(listener, new FilterTriple(null, uriRef4, literal2));
- mGraph.add(trpl1);
- mGraph.add(trpl2);
- mGraph.add(trpl3);
- mGraph.add(trpl4);
- listener.resetCumulatedEvents();
- Iterator<Triple> result = mGraph.filter(null, uriRef2, null);
- while (result.hasNext()) {
- result.next();
- result.remove();
- }
- List<GraphEvent> cumulatedEvents = listener.getCumulatedEvents();
- Assert.assertEquals(1, cumulatedEvents.size());
- Assert.assertTrue(cumulatedEvents.get(0) instanceof RemoveEvent);
- Assert.assertEquals(trpl2, listener.getEvents().get(0).getTriple());
- }
-
- @Test
- public void graphEventTestIteratorRemove() {
- Graph mGraph = getEmptyGraph();
- TestGraphListener listener = new TestGraphListener();
- mGraph.addGraphListener(listener, new FilterTriple(uriRef1, uriRef2, null));
- mGraph.addGraphListener(listener, new FilterTriple(bnode2, null, literal2));
- mGraph.addGraphListener(listener, new FilterTriple(null, uriRef4, literal2));
- mGraph.add(trpl1);
- mGraph.add(trpl2);
- mGraph.add(trpl3);
- mGraph.add(trpl4);
- listener.resetCumulatedEvents();
- Iterator<Triple> result = mGraph.iterator();
- while (result.hasNext()) {
- result.next();
- result.remove();
- }
- List<GraphEvent> cumulatedEvents = listener.getCumulatedEvents();
- Set<Triple> cumulatedTriples = getCumulatedTriples(cumulatedEvents);
- Assert.assertEquals(3, cumulatedEvents.size());
- Assert.assertTrue(cumulatedEvents.get(0) instanceof RemoveEvent);
- Assert.assertTrue(cumulatedTriples.contains(trpl2));
- Assert.assertTrue(cumulatedTriples.contains(trpl3));
- Assert.assertTrue(cumulatedTriples.contains(trpl4));
- }
-
- @Test
- public void graphEventTestClear() {
- Graph mGraph = getEmptyGraph();
- TestGraphListener listener = new TestGraphListener();
- mGraph.addGraphListener(listener, new FilterTriple(uriRef1, uriRef2, null));
- mGraph.addGraphListener(listener, new FilterTriple(bnode2, null, literal2));
- mGraph.addGraphListener(listener, new FilterTriple(null, uriRef4, literal2));
- mGraph.add(trpl1);
- mGraph.add(trpl2);
- mGraph.add(trpl3);
- mGraph.add(trpl4);
- listener.resetCumulatedEvents();
- mGraph.clear();
- List<GraphEvent> cumulatedEvents = listener.getCumulatedEvents();
- Set<Triple> cumulatedTriples = getCumulatedTriples(cumulatedEvents);
- Assert.assertEquals(3, cumulatedEvents.size());
- Assert.assertTrue(cumulatedEvents.get(0) instanceof RemoveEvent);
- Assert.assertTrue(cumulatedTriples.contains(trpl2));
- Assert.assertTrue(cumulatedTriples.contains(trpl3));
- Assert.assertTrue(cumulatedTriples.contains(trpl4));
- }
-
- private Set<Triple> getCumulatedTriples(List<GraphEvent> cumulatedEvents) {
- Set<Triple> triples = new HashSet<Triple>();
- for(GraphEvent event: cumulatedEvents) {
- triples.add(event.getTriple());
- }
- return triples;
- }
-
- @Test
- public void graphEventTestWithDelay() throws Exception{
- Graph mGraph = getEmptyGraph();
- TestGraphListener listener = new TestGraphListener();
- mGraph.addGraphListener(listener, new FilterTriple(uriRef1, uriRef2, null),
- 1000);
-
- Triple triple0 = new TripleImpl(uriRef2, uriRef2, literal1);
- Triple triple1 = new TripleImpl(uriRef1, uriRef2, uriRef1);
- Triple triple2 = new TripleImpl(uriRef1, uriRef2, literal1);
- Triple triple3 = new TripleImpl(uriRef1, uriRef2, bnode1);
- mGraph.add(triple0);
- mGraph.add(triple1);
- mGraph.add(triple2);
- mGraph.add(triple3);
- Thread.sleep(1500);
- Assert.assertEquals(3, listener.getEvents().size());
- Assert.assertEquals(triple1, listener.getEvents().get(0).getTriple());
- Assert.assertTrue(listener.getEvents().get(0) instanceof AddEvent);
- Assert.assertEquals(triple2, listener.getEvents().get(1).getTriple());
- Assert.assertTrue(listener.getEvents().get(0) instanceof AddEvent);
- Assert.assertEquals(triple3, listener.getEvents().get(2).getTriple());
- Assert.assertTrue(listener.getEvents().get(0) instanceof AddEvent);
- }
-
- private static class TestGraphListener implements GraphListener {
- private List<GraphEvent> events = null;
- private List<GraphEvent> cumulatedEvents = new ArrayList<GraphEvent>();
-
- @Override
- public void graphChanged(List<GraphEvent> events) {
- this.events = events;
- Iterator<GraphEvent> eventIter = events.iterator();
- while (eventIter.hasNext()) {
- GraphEvent graphEvent = eventIter.next();
- this.cumulatedEvents.add(graphEvent);
- }
+ /*
+ @Test
+ public void graphEventTestAddRemove() {
+ Graph mGraph = getEmptyGraph();
+ TestGraphListener listener = new TestGraphListener();
+ mGraph.addGraphListener(listener, new FilterTriple(uriRef1, uriRef2, null));
+ mGraph.addGraphListener(listener, new FilterTriple(bnode2, null, literal2));
+ mGraph.addGraphListener(listener, new FilterTriple(null, uriRef4, literal2));
+ mGraph.add(trpl1);
+ Assert.assertNull(listener.getEvents());
+ mGraph.add(trpl2);
+ Assert.assertEquals(1, listener.getEvents().size());
+ Assert.assertEquals(trpl2, listener.getEvents().get(0).getTriple());
+ Assert.assertTrue(listener.getEvents().get(0) instanceof AddEvent);
+ listener.resetEvents();
+ mGraph.remove(trpl2);
+ Assert.assertEquals(1, listener.getEvents().size());
+ Assert.assertEquals(trpl2, listener.getEvents().get(0).getTriple());
+ Assert.assertTrue(listener.getEvents().get(0) instanceof RemoveEvent);
+ listener.resetEvents();
+ mGraph.add(trpl3);
+ Assert.assertEquals(1, listener.getEvents().size());
+ Assert.assertEquals(trpl3, listener.getEvents().get(0).getTriple());
+ Assert.assertTrue(listener.getEvents().get(0) instanceof AddEvent);
+ listener.resetEvents();
+ mGraph.remove(trpl4);
+ Assert.assertNull(listener.getEvents());
}
- public List<GraphEvent> getEvents() {
- return events;
+ @Test
+ public void graphEventTestAddAllRemoveAll() {
+ Graph mGraph = getEmptyGraph();
+ TestGraphListener listener = new TestGraphListener();
+ mGraph.addGraphListener(listener, new FilterTriple(uriRef1, uriRef2, null));
+ mGraph.addGraphListener(listener, new FilterTriple(bnode2, null, literal2));
+ mGraph.addGraphListener(listener, new FilterTriple(null, uriRef4, literal2));
+ Graph triples = new SimpleGraph();
+ triples.add(trpl1);
+ triples.add(trpl2);
+ triples.add(trpl3);
+ triples.add(trpl4);
+ mGraph.addAll(triples);
+ List<GraphEvent> cumulatedEvents = listener.getCumulatedEvents();
+ Set<Triple> cumulatedTriples = getCumulatedTriples(cumulatedEvents);
+ Assert.assertEquals(3, cumulatedEvents.size());
+ Assert.assertTrue(cumulatedEvents.get(0) instanceof AddEvent);
+ Assert.assertTrue(cumulatedTriples.contains(trpl2));
+ Assert.assertTrue(cumulatedTriples.contains(trpl3));
+ Assert.assertTrue(cumulatedTriples.contains(trpl4));
+ listener.resetCumulatedEvents();
+ mGraph.removeAll(triples);
+ cumulatedEvents = listener.getCumulatedEvents();
+ cumulatedTriples = getCumulatedTriples(cumulatedEvents);
+ Assert.assertEquals(3, cumulatedEvents.size());
+ Assert.assertTrue(cumulatedEvents.get(0) instanceof RemoveEvent);
+ Assert.assertTrue(cumulatedTriples.contains(trpl2));
+ Assert.assertTrue(cumulatedTriples.contains(trpl3));
+ Assert.assertTrue(cumulatedTriples.contains(trpl4));
}
- public List<GraphEvent> getCumulatedEvents() {
- return cumulatedEvents;
+ @Test
+ public void graphEventTestFilterRemove() {
+ Graph mGraph = getEmptyGraph();
+ TestGraphListener listener = new TestGraphListener();
+ mGraph.addGraphListener(listener, new FilterTriple(uriRef1, uriRef2, null));
+ mGraph.addGraphListener(listener, new FilterTriple(bnode2, null, literal2));
+ mGraph.addGraphListener(listener, new FilterTriple(null, uriRef4, literal2));
+ mGraph.add(trpl1);
+ mGraph.add(trpl2);
+ mGraph.add(trpl3);
+ mGraph.add(trpl4);
+ listener.resetCumulatedEvents();
+ Iterator<Triple> result = mGraph.filter(null, uriRef2, null);
+ while (result.hasNext()) {
+ result.next();
+ result.remove();
+ }
+ List<GraphEvent> cumulatedEvents = listener.getCumulatedEvents();
+ Assert.assertEquals(1, cumulatedEvents.size());
+ Assert.assertTrue(cumulatedEvents.get(0) instanceof RemoveEvent);
+ Assert.assertEquals(trpl2, listener.getEvents().get(0).getTriple());
}
- public void resetEvents() {
- events = null;
+ @Test
+ public void graphEventTestIteratorRemove() {
+ Graph mGraph = getEmptyGraph();
+ TestGraphListener listener = new TestGraphListener();
+ mGraph.addGraphListener(listener, new FilterTriple(uriRef1, uriRef2, null));
+ mGraph.addGraphListener(listener, new FilterTriple(bnode2, null, literal2));
+ mGraph.addGraphListener(listener, new FilterTriple(null, uriRef4, literal2));
+ mGraph.add(trpl1);
+ mGraph.add(trpl2);
+ mGraph.add(trpl3);
+ mGraph.add(trpl4);
+ listener.resetCumulatedEvents();
+ Iterator<Triple> result = mGraph.iterator();
+ while (result.hasNext()) {
+ result.next();
+ result.remove();
+ }
+ List<GraphEvent> cumulatedEvents = listener.getCumulatedEvents();
+ Set<Triple> cumulatedTriples = getCumulatedTriples(cumulatedEvents);
+ Assert.assertEquals(3, cumulatedEvents.size());
+ Assert.assertTrue(cumulatedEvents.get(0) instanceof RemoveEvent);
+ Assert.assertTrue(cumulatedTriples.contains(trpl2));
+ Assert.assertTrue(cumulatedTriples.contains(trpl3));
+ Assert.assertTrue(cumulatedTriples.contains(trpl4));
}
- public void resetCumulatedEvents() {
- cumulatedEvents = new ArrayList<GraphEvent>();
+ @Test
+ public void graphEventTestClear() {
+ Graph mGraph = getEmptyGraph();
+ TestGraphListener listener = new TestGraphListener();
+ mGraph.addGraphListener(listener, new FilterTriple(uriRef1, uriRef2, null));
+ mGraph.addGraphListener(listener, new FilterTriple(bnode2, null, literal2));
+ mGraph.addGraphListener(listener, new FilterTriple(null, uriRef4, literal2));
+ mGraph.add(trpl1);
+ mGraph.add(trpl2);
+ mGraph.add(trpl3);
+ mGraph.add(trpl4);
+ listener.resetCumulatedEvents();
+ mGraph.clear();
+ List<GraphEvent> cumulatedEvents = listener.getCumulatedEvents();
+ Set<Triple> cumulatedTriples = getCumulatedTriples(cumulatedEvents);
+ Assert.assertEquals(3, cumulatedEvents.size());
+ Assert.assertTrue(cumulatedEvents.get(0) instanceof RemoveEvent);
+ Assert.assertTrue(cumulatedTriples.contains(trpl2));
+ Assert.assertTrue(cumulatedTriples.contains(trpl3));
+ Assert.assertTrue(cumulatedTriples.contains(trpl4));
}
- }
-*/
+
+ private Set<Triple> getCumulatedTriples(List<GraphEvent> cumulatedEvents) {
+ Set<Triple> triples = new HashSet<Triple>();
+ for(GraphEvent event: cumulatedEvents) {
+ triples.add(event.getTriple());
+ }
+ return triples;
+ }
+
+ @Test
+ public void graphEventTestWithDelay() throws Exception{
+ Graph mGraph = getEmptyGraph();
+ TestGraphListener listener = new TestGraphListener();
+ mGraph.addGraphListener(listener, new FilterTriple(uriRef1, uriRef2, null),
+ 1000);
+
+ Triple triple0 = new TripleImpl(uriRef2, uriRef2, literal1);
+ Triple triple1 = new TripleImpl(uriRef1, uriRef2, uriRef1);
+ Triple triple2 = new TripleImpl(uriRef1, uriRef2, literal1);
+ Triple triple3 = new TripleImpl(uriRef1, uriRef2, bnode1);
+ mGraph.add(triple0);
+ mGraph.add(triple1);
+ mGraph.add(triple2);
+ mGraph.add(triple3);
+ Thread.sleep(1500);
+ Assert.assertEquals(3, listener.getEvents().size());
+ Assert.assertEquals(triple1, listener.getEvents().get(0).getTriple());
+ Assert.assertTrue(listener.getEvents().get(0) instanceof AddEvent);
+ Assert.assertEquals(triple2, listener.getEvents().get(1).getTriple());
+ Assert.assertTrue(listener.getEvents().get(0) instanceof AddEvent);
+ Assert.assertEquals(triple3, listener.getEvents().get(2).getTriple());
+ Assert.assertTrue(listener.getEvents().get(0) instanceof AddEvent);
+ }
+
+ private static class TestGraphListener implements GraphListener {
+ private List<GraphEvent> events = null;
+ private List<GraphEvent> cumulatedEvents = new ArrayList<GraphEvent>();
+
+ @Override
+ public void graphChanged(List<GraphEvent> events) {
+ this.events = events;
+ Iterator<GraphEvent> eventIter = events.iterator();
+ while (eventIter.hasNext()) {
+ GraphEvent graphEvent = eventIter.next();
+ this.cumulatedEvents.add(graphEvent);
+ }
+ }
+
+ public List<GraphEvent> getEvents() {
+ return events;
+ }
+
+ public List<GraphEvent> getCumulatedEvents() {
+ return cumulatedEvents;
+ }
+
+ public void resetEvents() {
+ events = null;
+ }
+
+ public void resetCumulatedEvents() {
+ cumulatedEvents = new ArrayList<GraphEvent>();
+ }
+ }
+ */
private Collection<Triple> toCollection(Iterator<Triple> iterator) {
Collection<Triple> result = new ArrayList<Triple>();
while (iterator.hasNext()) {
@@ -549,15 +548,16 @@
/**
* Creates a new <code>Triple</code>.
- * @param subject the subject.
- * @param predicate the predicate.
- * @param object the object.
- * @throws IllegalArgumentException If an attribute is <code>null</code>.
+ *
+ * @param subject the subject.
+ * @param predicate the predicate.
+ * @param object the object.
+ * @throws IllegalArgumentException If an attribute is <code>null</code>.
*/
private Triple createTriple(String subject, String predicate,
- String object) {
+ String object) {
return new TripleImpl(new IRI(subject), new IRI(predicate),
new IRI(object));
}
-
+
}
diff --git a/api.impl/src/test/java/org/apache/clerezza/api/impl/graph/SimpleGraphTest.java b/api.impl/src/test/java/org/apache/clerezza/api/impl/graph/SimpleGraphTest.java
index cdfadab..bc48622 100644
--- a/api.impl/src/test/java/org/apache/clerezza/api/impl/graph/SimpleGraphTest.java
+++ b/api.impl/src/test/java/org/apache/clerezza/api/impl/graph/SimpleGraphTest.java
@@ -1,35 +1,32 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.graph;
+import org.apache.clerezza.api.IRI;
+import org.apache.clerezza.api.Triple;
import org.apache.clerezza.api.impl.TripleImpl;
+import org.junit.Assert;
+import org.junit.Test;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
-import org.junit.Assert;
-import org.junit.Test;
-import org.apache.clerezza.api.Triple;
-import org.apache.clerezza.api.IRI;
-
/**
- *
* @author mir
*/
public class SimpleGraphTest {
@@ -42,7 +39,7 @@
private Triple triple3 = new TripleImpl(uriRef3, uriRef1, uriRef3);
private Triple triple4 = new TripleImpl(uriRef1, uriRef3, uriRef2);
private Triple triple5 = new TripleImpl(uriRef2, uriRef3, uriRef2);
-
+
@Test
public void iteratorRemove() {
SimpleGraph stc = new SimpleGraph();
@@ -74,7 +71,7 @@
stc.removeAll(stc2);
Assert.assertEquals(2, stc.size());
}
-
+
@Test
public void filterIteratorRemove() {
SimpleGraph stc = new SimpleGraph();
@@ -82,7 +79,7 @@
stc.add(triple2);
stc.add(triple3);
stc.add(triple4);
- stc.add(triple5);
+ stc.add(triple5);
Iterator<Triple> iter = stc.filter(uriRef1, null, null);
while (iter.hasNext()) {
Triple triple = iter.next();
@@ -91,7 +88,7 @@
Assert.assertEquals(3, stc.size());
}
- @Test(expected=ConcurrentModificationException.class)
+ @Test(expected = ConcurrentModificationException.class)
public void remove() {
SimpleGraph stc = new SimpleGraph();
stc.setCheckConcurrency(true);
diff --git a/api.impl/src/test/java/org/apache/clerezza/api/impl/graphmatching/GraphMatcherTest.java b/api.impl/src/test/java/org/apache/clerezza/api/impl/graphmatching/GraphMatcherTest.java
index 4a39411..57208d9 100644
--- a/api.impl/src/test/java/org/apache/clerezza/api/impl/graphmatching/GraphMatcherTest.java
+++ b/api.impl/src/test/java/org/apache/clerezza/api/impl/graphmatching/GraphMatcherTest.java
@@ -1,36 +1,34 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.graphmatching;
-import org.apache.clerezza.api.Graph;
-import org.apache.clerezza.api.IRI;
-import org.apache.clerezza.api.impl.graph.SimpleMGraph;
-import org.apache.clerezza.api.impl.TripleImpl;
-
-import java.util.Map;
import org.apache.clerezza.api.BlankNode;
import org.apache.clerezza.api.BlankNodeOrIRI;
+import org.apache.clerezza.api.Graph;
+import org.apache.clerezza.api.IRI;
+import org.apache.clerezza.api.impl.TripleImpl;
+import org.apache.clerezza.api.impl.graph.SimpleMGraph;
import org.junit.Assert;
import org.junit.Test;
+import java.util.Map;
+
/**
- *
* @author reto
*/
public class GraphMatcherTest {
@@ -92,8 +90,8 @@
public void test6() {
Graph tc1 = new SimpleMGraph();
final BlankNode b11 = new BlankNode();
- tc1.add(new TripleImpl(new BlankNode(), u1,b11));
- tc1.add(new TripleImpl(new BlankNode(), u1,b11));
+ tc1.add(new TripleImpl(new BlankNode(), u1, b11));
+ tc1.add(new TripleImpl(new BlankNode(), u1, b11));
Graph tc2 = new SimpleMGraph();
tc2.add(new TripleImpl(new BlankNode(), u1, new BlankNode()));
final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
@@ -110,7 +108,7 @@
}
Graph result = new SimpleMGraph();
BlankNodeOrIRI lastNode = firstNode;
- for (int i = 0; i < (size-1); i++) {
+ for (int i = 0; i < (size - 1); i++) {
final BlankNode newNode = new BlankNode();
result.add(new TripleImpl(lastNode, u1, newNode));
lastNode = newNode;
@@ -140,10 +138,10 @@
@Test
public void test9() {
BlankNodeOrIRI crossing = new IRI("http://example.org/");
- Graph tc1 = generateCircle(2,crossing);
- tc1.addAll(generateCircle(3,crossing));
- Graph tc2 = generateCircle(2,crossing);
- tc2.addAll(generateCircle(3,crossing));
+ Graph tc1 = generateCircle(2, crossing);
+ tc1.addAll(generateCircle(3, crossing));
+ Graph tc2 = generateCircle(2, crossing);
+ tc2.addAll(generateCircle(3, crossing));
Assert.assertEquals(5, tc1.size());
final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
Assert.assertNotNull(mapping);
@@ -154,11 +152,11 @@
@Test
public void test10() {
BlankNodeOrIRI crossing1 = new BlankNode();
- Graph tc1 = generateCircle(2,crossing1);
- tc1.addAll(generateCircle(3,crossing1));
+ Graph tc1 = generateCircle(2, crossing1);
+ tc1.addAll(generateCircle(3, crossing1));
BlankNodeOrIRI crossing2 = new BlankNode();
- Graph tc2 = generateCircle(2,crossing2);
- tc2.addAll(generateCircle(3,crossing2));
+ Graph tc2 = generateCircle(2, crossing2);
+ tc2.addAll(generateCircle(3, crossing2));
Assert.assertEquals(5, tc1.size());
final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
Assert.assertNotNull(mapping);
@@ -169,11 +167,11 @@
@Test
public void test11() {
BlankNodeOrIRI crossing1 = new BlankNode();
- Graph tc1 = generateCircle(2,crossing1);
- tc1.addAll(generateCircle(4,crossing1));
+ Graph tc1 = generateCircle(2, crossing1);
+ tc1.addAll(generateCircle(4, crossing1));
BlankNodeOrIRI crossing2 = new BlankNode();
- Graph tc2 = generateCircle(3,crossing2);
- tc2.addAll(generateCircle(3,crossing2));
+ Graph tc2 = generateCircle(3, crossing2);
+ tc2.addAll(generateCircle(3, crossing2));
Assert.assertEquals(6, tc1.size());
final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
Assert.assertNull(mapping);
@@ -182,11 +180,11 @@
@Test
public void test12() {
BlankNodeOrIRI start1 = new BlankNode();
- Graph tc1 = Utils4Testing.generateLine(4,start1);
- tc1.addAll(Utils4Testing.generateLine(5,start1));
+ Graph tc1 = Utils4Testing.generateLine(4, start1);
+ tc1.addAll(Utils4Testing.generateLine(5, start1));
BlankNodeOrIRI start2 = new BlankNode();
- Graph tc2 = Utils4Testing.generateLine(5,start2);
- tc2.addAll(Utils4Testing.generateLine(4,start2));
+ Graph tc2 = Utils4Testing.generateLine(5, start2);
+ tc2.addAll(Utils4Testing.generateLine(4, start2));
Assert.assertEquals(9, tc1.size());
final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
Assert.assertNotNull(mapping);
@@ -196,11 +194,11 @@
@Test
public void test13() {
BlankNodeOrIRI start1 = new BlankNode();
- Graph tc1 = Utils4Testing.generateLine(4,start1);
- tc1.addAll(Utils4Testing.generateLine(5,start1));
+ Graph tc1 = Utils4Testing.generateLine(4, start1);
+ tc1.addAll(Utils4Testing.generateLine(5, start1));
BlankNodeOrIRI start2 = new BlankNode();
- Graph tc2 = Utils4Testing.generateLine(3,start2);
- tc2.addAll(Utils4Testing.generateLine(3,start2));
+ Graph tc2 = Utils4Testing.generateLine(3, start2);
+ tc2.addAll(Utils4Testing.generateLine(3, start2));
Assert.assertEquals(9, tc1.size());
final Map<BlankNode, BlankNode> mapping = GraphMatcher.getValidMapping(tc1, tc2);
Assert.assertNull(mapping);
diff --git a/api.impl/src/test/java/org/apache/clerezza/api/impl/graphmatching/HashMatchingTest.java b/api.impl/src/test/java/org/apache/clerezza/api/impl/graphmatching/HashMatchingTest.java
index 74f76e1..1d96575 100644
--- a/api.impl/src/test/java/org/apache/clerezza/api/impl/graphmatching/HashMatchingTest.java
+++ b/api.impl/src/test/java/org/apache/clerezza/api/impl/graphmatching/HashMatchingTest.java
@@ -1,35 +1,32 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.graphmatching;
-
-import java.util.Map;
-
import org.apache.clerezza.api.BlankNode;
import org.apache.clerezza.api.BlankNodeOrIRI;
import org.apache.clerezza.api.Graph;
import org.junit.Assert;
import org.junit.Test;
+import java.util.Map;
+
/**
- *
* @author reto
*/
public class HashMatchingTest {
@@ -37,11 +34,11 @@
@Test
public void twoLine() throws GraphNotIsomorphicException {
BlankNodeOrIRI start1 = new BlankNode();
- Graph tc1 = Utils4Testing.generateLine(4,start1);
- tc1.addAll(Utils4Testing.generateLine(5,start1));
+ Graph tc1 = Utils4Testing.generateLine(4, start1);
+ tc1.addAll(Utils4Testing.generateLine(5, start1));
BlankNodeOrIRI start2 = new BlankNode();
- Graph tc2 = Utils4Testing.generateLine(5,start2);
- tc2.addAll(Utils4Testing.generateLine(4,start2));
+ Graph tc2 = Utils4Testing.generateLine(5, start2);
+ tc2.addAll(Utils4Testing.generateLine(4, start2));
Assert.assertEquals(9, tc1.size());
final Map<BlankNode, BlankNode> mapping = new HashMatching(tc1, tc2).getMatchings();
Assert.assertNotNull(mapping);
diff --git a/api.impl/src/test/java/org/apache/clerezza/api/impl/graphmatching/PermutationIteratorTest.java b/api.impl/src/test/java/org/apache/clerezza/api/impl/graphmatching/PermutationIteratorTest.java
index bc31dd6..e1ad191 100644
--- a/api.impl/src/test/java/org/apache/clerezza/api/impl/graphmatching/PermutationIteratorTest.java
+++ b/api.impl/src/test/java/org/apache/clerezza/api/impl/graphmatching/PermutationIteratorTest.java
@@ -1,33 +1,32 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.graphmatching;
+import org.junit.Assert;
+import org.junit.Test;
+
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.junit.Assert;
-import org.junit.Test;
/**
- *
* @author reto
*/
public class PermutationIteratorTest {
diff --git a/api.impl/src/test/java/org/apache/clerezza/api/impl/graphmatching/Utils4Testing.java b/api.impl/src/test/java/org/apache/clerezza/api/impl/graphmatching/Utils4Testing.java
index 9dc1a8f..44c386d 100644
--- a/api.impl/src/test/java/org/apache/clerezza/api/impl/graphmatching/Utils4Testing.java
+++ b/api.impl/src/test/java/org/apache/clerezza/api/impl/graphmatching/Utils4Testing.java
@@ -1,33 +1,31 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.graphmatching;
import org.apache.clerezza.api.BlankNode;
+import org.apache.clerezza.api.BlankNodeOrIRI;
import org.apache.clerezza.api.Graph;
import org.apache.clerezza.api.IRI;
-import org.apache.clerezza.api.impl.graph.SimpleMGraph;
import org.apache.clerezza.api.impl.TripleImpl;
-import org.apache.clerezza.api.BlankNodeOrIRI;
+import org.apache.clerezza.api.impl.graph.SimpleMGraph;
/**
- *
* @author reto
*/
public class Utils4Testing {
diff --git a/api.impl/src/test/java/org/apache/clerezza/api/impl/literal/LiteralFactoryTest.java b/api.impl/src/test/java/org/apache/clerezza/api/impl/literal/LiteralFactoryTest.java
index bba9db6..629fa6b 100644
--- a/api.impl/src/test/java/org/apache/clerezza/api/impl/literal/LiteralFactoryTest.java
+++ b/api.impl/src/test/java/org/apache/clerezza/api/impl/literal/LiteralFactoryTest.java
@@ -1,44 +1,42 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.literal;
-
-import org.apache.clerezza.api.Literal;
import org.apache.clerezza.api.IRI;
-import java.util.Arrays;
-import java.util.Date;
-
+import org.apache.clerezza.api.Literal;
import org.junit.Assert;
import org.junit.Test;
+import java.util.Arrays;
+import java.util.Date;
+
/**
- *
* @author reto
*/
public class LiteralFactoryTest {
-
+
/**
* Test that a NoConvertorException thrown for an unsupported convertor
*/
- @Test(expected=NoConvertorException.class)
+ @Test(expected = NoConvertorException.class)
public void unavailableConvertor() {
- Object value = new Object() {};
+ Object value = new Object() {
+ };
LiteralFactory.getInstance().createTypedLiteral(value);
}
diff --git a/api.impl/src/test/java/org/apache/clerezza/api/impl/literal/PlainLiteralImplTest.java b/api.impl/src/test/java/org/apache/clerezza/api/impl/literal/PlainLiteralImplTest.java
index ff55388..10aad34 100644
--- a/api.impl/src/test/java/org/apache/clerezza/api/impl/literal/PlainLiteralImplTest.java
+++ b/api.impl/src/test/java/org/apache/clerezza/api/impl/literal/PlainLiteralImplTest.java
@@ -1,53 +1,49 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.literal;
-import org.junit.Test;
-
import org.apache.clerezza.api.Language;
import org.apache.clerezza.api.Literal;
import org.junit.Assert;
+import org.junit.Test;
/**
- *
* @author reto
- *
*/
-
public class PlainLiteralImplTest {
-
- @Test public void plainLiteralEquality() {
+ @Test
+ public void plainLiteralEquality() {
String stringValue = "some text";
Literal literal1 = new PlainLiteralImpl(stringValue);
- Literal literal2 = new PlainLiteralImpl(stringValue);
+ Literal literal2 = new PlainLiteralImpl(stringValue);
Assert.assertEquals(literal1, literal2);
Assert.assertEquals(literal1.hashCode(), literal2.hashCode());
Literal literal3 = new PlainLiteralImpl("something else");
Assert.assertFalse(literal1.equals(literal3));
}
-
- @Test public void languageLiteralEquality() {
+
+ @Test
+ public void languageLiteralEquality() {
String stringValue = "some text";
Language lang = new Language("en-ca");
Literal literal1 = new PlainLiteralImpl(stringValue, lang);
- Literal literal2 = new PlainLiteralImpl(stringValue, lang);
+ Literal literal2 = new PlainLiteralImpl(stringValue, lang);
Assert.assertEquals(literal1, literal2);
Assert.assertEquals(literal1.hashCode(), literal2.hashCode());
Language lang2 = new Language("de");
@@ -61,7 +57,8 @@
/**
* hashCode of the lexical form plus the hashCode of the locale
*/
- @Test public void checkHashCode() {
+ @Test
+ public void checkHashCode() {
String stringValue = "some text";
Language language = new Language("en");
Literal literal = new PlainLiteralImpl(stringValue, language);
diff --git a/api.impl/src/test/java/org/apache/clerezza/api/impl/literal/TripleImplTest.java b/api.impl/src/test/java/org/apache/clerezza/api/impl/literal/TripleImplTest.java
index 99e59ce..85e9729 100644
--- a/api.impl/src/test/java/org/apache/clerezza/api/impl/literal/TripleImplTest.java
+++ b/api.impl/src/test/java/org/apache/clerezza/api/impl/literal/TripleImplTest.java
@@ -1,57 +1,45 @@
/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package org.apache.clerezza.api.impl.simple;
-/*
- *
- * 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
+ * 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.
- *
-*/
+ * 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.api.impl.simple;
-
+import junit.framework.Assert;
import org.apache.clerezza.api.BlankNodeOrIRI;
import org.apache.clerezza.api.IRI;
import org.apache.clerezza.api.RDFTerm;
import org.apache.clerezza.api.Triple;
-import org.apache.clerezza.api.impl.literal.PlainLiteralImpl;
import org.apache.clerezza.api.impl.TripleImpl;
+import org.apache.clerezza.api.impl.literal.PlainLiteralImpl;
import org.junit.Test;
-import junit.framework.Assert;
/**
- *
* @author reto
- *
*/
-
public class TripleImplTest {
-
-
- @Test public void tripleEquality() {
+
+ @Test
+ public void tripleEquality() {
BlankNodeOrIRI subject = new IRI("http://example.org/");
IRI predicate = new IRI("http://example.org/property");
RDFTerm object = new PlainLiteralImpl("property value");
Triple triple1 = new TripleImpl(subject, predicate, object);
Triple triple2 = new TripleImpl(subject, predicate, object);
Assert.assertEquals(triple1.hashCode(), triple2.hashCode());
- Assert.assertEquals(triple1, triple2);
+ Assert.assertEquals(triple1, triple2);
}
}
diff --git a/api.impl/src/test/java/org/apache/clerezza/api/impl/literal/TypedLiteralImplTest.java b/api.impl/src/test/java/org/apache/clerezza/api/impl/literal/TypedLiteralImplTest.java
index 8589c4e..50f1ca7 100644
--- a/api.impl/src/test/java/org/apache/clerezza/api/impl/literal/TypedLiteralImplTest.java
+++ b/api.impl/src/test/java/org/apache/clerezza/api/impl/literal/TypedLiteralImplTest.java
@@ -1,49 +1,40 @@
/*
- * 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
+ * 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.
+ * 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.api.impl.simple;
+import junit.framework.Assert;
import org.apache.clerezza.api.IRI;
+import org.apache.clerezza.api.Literal;
import org.apache.clerezza.api.impl.literal.TypedLiteralImpl;
import org.junit.Test;
-import junit.framework.Assert;
-import org.apache.clerezza.api.Literal;
/**
- *
- * @author reto/**
- *
- * @author reto/**
- *
- * @author reto/**
- *
* @author reto
- *
*/
-
public class TypedLiteralImplTest {
-
-
- @Test public void typedLiteralEquality() {
+
+
+ @Test
+ public void typedLiteralEquality() {
String stringValue = "some text";
IRI uriRef = new IRI("http://example.org/datatypes/magic");
Literal literal1 = new TypedLiteralImpl(stringValue, uriRef);
- Literal literal2 = new TypedLiteralImpl(stringValue, uriRef);
+ Literal literal2 = new TypedLiteralImpl(stringValue, uriRef);
Assert.assertEquals(literal1, literal2);
Assert.assertEquals(literal1.hashCode(), literal2.hashCode());
Literal literal3 = new TypedLiteralImpl("something else", uriRef);
@@ -53,14 +44,14 @@
Assert.assertFalse(literal1.equals(literal4));
}
-
/**
* The hascode is equals to the hascode of the lexical form plus the hashcode of the dataTyp
*/
- @Test public void checkHashCode() {
+ @Test
+ public void checkHashCode() {
String stringValue = "some text";
IRI uriRef = new IRI("http://example.org/datatypes/magic");
- Literal literal = new TypedLiteralImpl(stringValue, uriRef);
+ Literal literal = new TypedLiteralImpl(stringValue, uriRef);
Assert.assertEquals(stringValue.hashCode() + uriRef.hashCode(), literal.hashCode());
}