|
From: <lh...@us...> - 2008-11-14 13:35:25
|
Revision: 189
http://tinytim.svn.sourceforge.net/tinytim/?rev=189&view=rev
Author: lheuer
Date: 2008-11-14 13:35:18 +0000 (Fri, 14 Nov 2008)
Log Message:
-----------
- Moved IIndexManager into internal.api
- Removed remove(Topic/Association) from ITopicMap and added AbstractTopicMap instead
- Added BooleanLiteral
- More docs
- Minor changes
Modified Paths:
--------------
tinytim/trunk/src/main/java/org/tinytim/core/AssociationImpl.java
tinytim/trunk/src/main/java/org/tinytim/core/ConstructImpl.java
tinytim/trunk/src/main/java/org/tinytim/core/DatatypeAwareConstruct.java
tinytim/trunk/src/main/java/org/tinytim/core/IdGenerator.java
tinytim/trunk/src/main/java/org/tinytim/core/IdentityManager.java
tinytim/trunk/src/main/java/org/tinytim/core/MemoryConstructFactory.java
tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMap.java
tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMapSystem.java
tinytim/trunk/src/main/java/org/tinytim/core/NameImpl.java
tinytim/trunk/src/main/java/org/tinytim/core/OccurrenceImpl.java
tinytim/trunk/src/main/java/org/tinytim/core/Scope.java
tinytim/trunk/src/main/java/org/tinytim/core/ScopedImpl.java
tinytim/trunk/src/main/java/org/tinytim/core/TopicImpl.java
tinytim/trunk/src/main/java/org/tinytim/core/TypedImpl.java
tinytim/trunk/src/main/java/org/tinytim/core/VariantImpl.java
tinytim/trunk/src/main/java/org/tinytim/core/value/DecimalLiteral.java
tinytim/trunk/src/main/java/org/tinytim/core/value/IntegerLiteral.java
tinytim/trunk/src/main/java/org/tinytim/core/value/Literal.java
tinytim/trunk/src/main/java/org/tinytim/core/value/LiteralNormalizer.java
tinytim/trunk/src/main/java/org/tinytim/core/value/LocatorImpl.java
tinytim/trunk/src/main/java/org/tinytim/index/AbstractIndex.java
tinytim/trunk/src/main/java/org/tinytim/index/IndexManager.java
tinytim/trunk/src/main/java/org/tinytim/index/LiteralIndexImpl.java
tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndexImpl.java
tinytim/trunk/src/main/java/org/tinytim/index/TypeInstanceIndexImpl.java
tinytim/trunk/src/main/java/org/tinytim/internal/api/IConstant.java
tinytim/trunk/src/main/java/org/tinytim/internal/api/IConstructFactory.java
tinytim/trunk/src/main/java/org/tinytim/internal/api/IIndexManagerAware.java
tinytim/trunk/src/main/java/org/tinytim/internal/api/IName.java
tinytim/trunk/src/main/java/org/tinytim/internal/api/IOccurrence.java
tinytim/trunk/src/main/java/org/tinytim/internal/api/ITopic.java
tinytim/trunk/src/main/java/org/tinytim/internal/api/ITopicMap.java
tinytim/trunk/src/main/java/org/tinytim/internal/api/IVariant.java
tinytim/trunk/src/main/java/org/tinytim/internal/utils/CollectionFactory.java
tinytim/trunk/src/main/java/org/tinytim/internal/utils/MergeUtils.java
tinytim/trunk/src/main/java/org/tinytim/internal/utils/TroveCollectionFactory.java
tinytim/trunk/src/main/java/org/tinytim/utils/Property.java
tinytim/trunk/src/main/java/org/tinytim/utils/TopicUtils.java
tinytim/trunk/src/main/java/org/tinytim/utils/TypeInstanceConverter.java
tinytim/trunk/src/main/java/org/tinytim/voc/XTM10.java
tinytim/trunk/src/test/java/org/tinytim/core/TinyTimTestCase.java
tinytim/trunk/src/test/java/org/tinytim/core/value/TestLiteral.java
Added Paths:
-----------
tinytim/trunk/src/main/java/org/tinytim/core/AbstractTopicMap.java
tinytim/trunk/src/main/java/org/tinytim/core/value/BooleanLiteral.java
tinytim/trunk/src/main/java/org/tinytim/internal/api/IIndexManager.java
Removed Paths:
-------------
tinytim/trunk/src/main/java/org/tinytim/index/IIndexManager.java
Added: tinytim/trunk/src/main/java/org/tinytim/core/AbstractTopicMap.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/AbstractTopicMap.java (rev 0)
+++ tinytim/trunk/src/main/java/org/tinytim/core/AbstractTopicMap.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2008 Lars Heuer (heuer[at]semagia.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.tinytim.core;
+
+import org.tinytim.internal.api.ITopicMap;
+import org.tmapi.core.Association;
+import org.tmapi.core.Topic;
+
+/**
+ *
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+abstract class AbstractTopicMap extends ConstructImpl implements ITopicMap {
+
+ protected AbstractTopicMap() {
+ super(null);
+ }
+
+ abstract void removeAssociation(Association assoc);
+
+ abstract void removeTopic(Topic topic);
+
+}
Property changes on: tinytim/trunk/src/main/java/org/tinytim/core/AbstractTopicMap.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date Id
Added: svn:eol-style
+ native
Modified: tinytim/trunk/src/main/java/org/tinytim/core/AssociationImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/AssociationImpl.java 2008-11-13 18:10:28 UTC (rev 188)
+++ tinytim/trunk/src/main/java/org/tinytim/core/AssociationImpl.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -154,7 +154,7 @@
* @see org.tmapi.core.TopicMapObject#remove()
*/
public void remove() {
- _tm.removeAssociation(this);
+ ((AbstractTopicMap) _tm).removeAssociation(this);
for (Role role: CollectionFactory.createList(_roles)) {
role.remove();
}
Modified: tinytim/trunk/src/main/java/org/tinytim/core/ConstructImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/ConstructImpl.java 2008-11-13 18:10:28 UTC (rev 188)
+++ tinytim/trunk/src/main/java/org/tinytim/core/ConstructImpl.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -42,7 +42,7 @@
protected Construct _parent;
private Set<Locator> _iids;
- ConstructImpl(ITopicMap topicMap) {
+ protected ConstructImpl(ITopicMap topicMap) {
_tm = topicMap;
}
@@ -147,49 +147,49 @@
}
/* (non-Javadoc)
- * @see org.tinytim.core.IConstruct#isAssociation()
+ * @see org.tinytim.internal.api.IConstruct#isAssociation()
*/
public boolean isAssociation() {
return false;
}
/* (non-Javadoc)
- * @see org.tinytim.core.IConstruct#isName()
+ * @see org.tinytim.internal.api.IConstruct#isName()
*/
public boolean isName() {
return false;
}
/* (non-Javadoc)
- * @see org.tinytim.core.IConstruct#isOccurrence()
+ * @see org.tinytim.internal.api.IConstruct#isOccurrence()
*/
public boolean isOccurrence() {
return false;
}
/* (non-Javadoc)
- * @see org.tinytim.core.IConstruct#isRole()
+ * @see org.tinytim.internal.api.IConstruct#isRole()
*/
public boolean isRole() {
return false;
}
/* (non-Javadoc)
- * @see org.tinytim.core.IConstruct#isTopic()
+ * @see org.tinytim.internal.api.IConstruct#isTopic()
*/
public boolean isTopic() {
return false;
}
/* (non-Javadoc)
- * @see org.tinytim.core.IConstruct#isTopicMap()
+ * @see org.tinytim.internal.api.IConstruct#isTopicMap()
*/
public boolean isTopicMap() {
return false;
}
/* (non-Javadoc)
- * @see org.tinytim.core.IConstruct#isVariant()
+ * @see org.tinytim.internal.api.IConstruct#isVariant()
*/
public boolean isVariant() {
return false;
Modified: tinytim/trunk/src/main/java/org/tinytim/core/DatatypeAwareConstruct.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/DatatypeAwareConstruct.java 2008-11-13 18:10:28 UTC (rev 188)
+++ tinytim/trunk/src/main/java/org/tinytim/core/DatatypeAwareConstruct.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -42,11 +42,11 @@
private ILiteral _literal;
- DatatypeAwareConstruct(ITopicMap tm) {
+ protected DatatypeAwareConstruct(ITopicMap tm) {
super(tm);
}
- DatatypeAwareConstruct(ITopicMap topicMap, Topic type, ILiteral literal, IScope scope) {
+ protected DatatypeAwareConstruct(ITopicMap topicMap, Topic type, ILiteral literal, IScope scope) {
super(topicMap, type, scope);
_literal = literal;
}
Modified: tinytim/trunk/src/main/java/org/tinytim/core/IdGenerator.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/IdGenerator.java 2008-11-13 18:10:28 UTC (rev 188)
+++ tinytim/trunk/src/main/java/org/tinytim/core/IdGenerator.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -28,7 +28,7 @@
*/
final class IdGenerator {
- private static final AtomicLong _COUNTER = new AtomicLong();
+ private static final AtomicLong _COUNTER = new AtomicLong(1);
/**
* Returns the next identifier.
Modified: tinytim/trunk/src/main/java/org/tinytim/core/IdentityManager.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/IdentityManager.java 2008-11-13 18:10:28 UTC (rev 188)
+++ tinytim/trunk/src/main/java/org/tinytim/core/IdentityManager.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -44,13 +44,13 @@
*/
final class IdentityManager implements IEventPublisherAware {
- private Map<Locator, Topic> _sid2Topic;
- private Map<Locator, Topic> _slo2Topic;
- private Map<Locator, IConstruct> _iid2Construct;
- private Map<String, IConstruct> _id2Construct;
+ private final Map<Locator, Topic> _sid2Topic;
+ private final Map<Locator, Topic> _slo2Topic;
+ private final Map<Locator, IConstruct> _iid2Construct;
+ private final Map<String, IConstruct> _id2Construct;
IdentityManager(MemoryTopicMap tm) {
- _id2Construct = CollectionFactory.createIdentityMap(IConstant.IDENTITY_ID2CONSTRUCT_SIZE);
+ _id2Construct = CollectionFactory.createMap(IConstant.IDENTITY_ID2CONSTRUCT_SIZE);
_sid2Topic = CollectionFactory.createIdentityMap(IConstant.IDENTITY_SID2TOPIC_SIZE);
_slo2Topic = CollectionFactory.createIdentityMap(IConstant.IDENTITY_SLO2TOPIC_SIZE);
_iid2Construct = CollectionFactory.createIdentityMap(IConstant.IDENTITY_IID2CONSTRUCT_SIZE);
@@ -59,7 +59,7 @@
}
/* (non-Javadoc)
- * @see org.tinytim.core.IEventPublisherAware#subscribe(org.tinytim.core.IEventPublisher)
+ * @see org.tinytim.internal.api.IEventPublisherAware#subscribe(org.tinytim.internal.api.IEventPublisher)
*/
public void subscribe(IEventPublisher publisher) {
IEventHandler handler = new TopicMapsConstructAddHandler();
@@ -93,7 +93,7 @@
}
/* (non-Javadoc)
- * @see org.tinytim.core.IEventPublisherAware#unsubscribe(org.tinytim.core.IEventPublisher)
+ * @see org.tinytim.internal.api.IEventPublisherAware#unsubscribe(org.tinytim.internal.api.IEventPublisher)
*/
public void unsubscribe(IEventPublisher publisher) {
// noop.
@@ -106,17 +106,18 @@
*/
private void _register(IConstruct construct) {
ConstructImpl c = (ConstructImpl) construct;
- if (c._id == null) {
- String id = "" + IdGenerator.nextId();
- c._id = id.intern();
+ String id = c._id;
+ if (id == null) {
+ id = "" + IdGenerator.nextId();
}
- if (!_id2Construct.containsKey(c._id)) {
- _id2Construct.put(c._id, c);
+ if (!_id2Construct.containsKey(id)) {
+ _id2Construct.put(id, c);
+ c._id = id;
}
}
/**
- * Unregisteres the specified <code>construct</code>.
+ * Unregisteres the specified <tt>construct</tt>.
*
* @param construct The Topic Maps construct to unregister.
*/
@@ -128,7 +129,7 @@
* Returns a Topic Maps construct by its identifier.
*
* @param id The identifier.
- * @return A Topic Maps construct with the <code>id</code> or <code>null</code>.
+ * @return A Topic Maps construct with the <tt>id</tt> or <tt>null</tt>.
*/
public Construct getConstructById(String id) {
return _id2Construct.get(id);
@@ -138,7 +139,7 @@
* Returns a topic by its subject identifier.
*
* @param sid The subject identifier.
- * @return A topic with the <code>sid</code> or <code>null</code>.
+ * @return A topic with the <tt>sid</tt> or <tt>null</tt>.
*/
public Topic getTopicBySubjectIdentifier(Locator sid) {
return _sid2Topic.get(sid);
@@ -148,7 +149,7 @@
* Returns a topic by its subject locator.
*
* @param slo The subject locator.
- * @return A topic with the <code>slo</code> or <code>null</code>.
+ * @return A topic with the <tt>slo</tt> or <tt>null</tt>.
*/
public Topic getTopicBySubjectLocator(Locator slo) {
return _slo2Topic.get(slo);
@@ -158,17 +159,17 @@
* Returns a Topic Maps construct by its item identifier.
*
* @param iid The item identifier.
- * @return A Topic Maps construct with the <code>iid</code> or <code>null</code>.
+ * @return A Topic Maps construct with the <tt>iid</tt> or <tt>null</tt>.
*/
public Construct getConstructByItemIdentifier(Locator iid) {
return _iid2Construct.get(iid);
}
public void close() {
- _id2Construct = null;
- _iid2Construct = null;
- _sid2Topic = null;
- _slo2Topic = null;
+ _id2Construct.clear();
+ _iid2Construct.clear();
+ _sid2Topic.clear();
+ _slo2Topic.clear();
}
private class TopicMapsConstructAddHandler implements IEventHandler {
Modified: tinytim/trunk/src/main/java/org/tinytim/core/MemoryConstructFactory.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/MemoryConstructFactory.java 2008-11-13 18:10:28 UTC (rev 188)
+++ tinytim/trunk/src/main/java/org/tinytim/core/MemoryConstructFactory.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -29,7 +29,7 @@
*
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
final class MemoryConstructFactory implements IConstructFactory {
Modified: tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMap.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMap.java 2008-11-13 18:10:28 UTC (rev 188)
+++ tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMap.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -18,19 +18,17 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import org.tinytim.core.value.Literal;
import org.tinytim.index.IndexManager;
-import org.tinytim.index.IIndexManager;
import org.tinytim.internal.api.Event;
import org.tinytim.internal.api.IConstant;
import org.tinytim.internal.api.IConstruct;
import org.tinytim.internal.api.IConstructFactory;
import org.tinytim.internal.api.IEventHandler;
-import org.tinytim.internal.api.IEventPublisher;
+import org.tinytim.internal.api.IIndexManager;
import org.tinytim.internal.api.ITopicMap;
import org.tinytim.internal.utils.Check;
import org.tinytim.internal.utils.CollectionFactory;
@@ -55,8 +53,7 @@
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
* @version $Rev$ - $Date$
*/
-final class MemoryTopicMap extends ConstructImpl implements ITopicMap,
- IEventHandler, IEventPublisher {
+final class MemoryTopicMap extends AbstractTopicMap implements ITopicMap {
private final IConstructFactory _factory;
private final IdentityManager _identityManager;
@@ -66,11 +63,11 @@
private final Set<Association> _assocs;
private AbstractTopicMapSystem _sys;
private Topic _reifier;
- private final Map<Event, List<IEventHandler>> _evtHandlers;
+ private final Map<Event, Collection<IEventHandler>> _evtHandlers;
private EventMultiplier _eventMultiplier;
MemoryTopicMap(AbstractTopicMapSystem sys, Locator locator) {
- super(null);
+ super();
super._tm = this;
_factory = new MemoryConstructFactory(this);
_sys = sys;
@@ -118,19 +115,10 @@
}
/* (non-Javadoc)
- * @see org.tinytim.core.ITopicMap#createTopicWithoutIdentity()
- */
- public TopicImpl createTopicWithoutIdentity() {
- TopicImpl topic = new TopicImpl(this);
- addTopic(topic);
- return topic;
- }
-
- /* (non-Javadoc)
* @see org.tmapi.core.TopicMap#createTopic()
*/
public Topic createTopic() {
- Topic topic = createTopicWithoutIdentity();
+ Topic topic = _factory.createTopic();
topic.addItemIdentifier(Literal.createIRI("urn:x-tinytim:" + IdGenerator.nextId()));
return topic;
}
@@ -156,7 +144,7 @@
return topic;
}
}
- TopicImpl topic = createTopicWithoutIdentity();
+ Topic topic = _factory.createTopic();
topic.addItemIdentifier(iid);
return topic;
}
@@ -180,11 +168,14 @@
return topic;
}
}
- topic = createTopicWithoutIdentity();
+ topic = _factory.createTopic();
topic.addSubjectIdentifier(sid);
return topic;
}
+ /* (non-Javadoc)
+ * @see org.tmapi.core.TopicMap#createTopicBySubjectLocator(org.tmapi.core.Locator)
+ */
public Topic createTopicBySubjectLocator(Locator slo) {
if (slo == null) {
throw new ModelConstraintException(null, "The subject locator must not be null");
@@ -193,7 +184,7 @@
if (topic != null) {
return topic;
}
- topic = createTopicWithoutIdentity();
+ topic = _factory.createTopic();
topic.addSubjectLocator(slo);
return topic;
}
@@ -207,12 +198,13 @@
if (topic._parent == this) {
return;
}
+ assert topic._parent == null;
_fireEvent(Event.ADD_TOPIC, null, topic);
topic._parent = this;
_topics.add(topic);
}
- public void removeTopic(Topic topic_) {
+ void removeTopic(Topic topic_) {
TopicImpl topic = (TopicImpl) topic_;
if (topic._parent != this) {
return;
@@ -252,7 +244,7 @@
_assocs.add(assoc);
}
- public void removeAssociation(Association assoc_) {
+ void removeAssociation(Association assoc_) {
AssociationImpl assoc = (AssociationImpl) assoc_;
if (assoc._parent != this) {
return;
@@ -304,7 +296,7 @@
}
/* (non-Javadoc)
- * @see org.tinytim.IReifiable#setReifier(org.tmapi.core.Topic)
+ * @see org.tmapi.core.Reifiable#setReifier(org.tmapi.core.Topic)
*/
public void setReifier(Topic reifier) {
if (_reifier == reifier) {
@@ -382,14 +374,14 @@
}
/* (non-Javadoc)
- * @see org.tinytim.IEventHandler#handleEvent(org.tinytim.Event, org.tinytim.IConstruct, java.lang.Object, java.lang.Object)
+ * @see org.tinytim.internal.api.IEventHandler#handleEvent(org.tinytim.internal.api.Event, org.tinytim.internal.api.IConstruct, java.lang.Object, java.lang.Object)
*/
public void handleEvent(Event evt, IConstruct sender, Object oldValue, Object newValue) {
if (!_evtHandlers.containsKey(evt)) {
_eventMultiplier.handleEvent(evt, sender, oldValue, newValue);
return;
}
- List<IEventHandler> handlers = _evtHandlers.get(evt);
+ Collection<IEventHandler> handlers = _evtHandlers.get(evt);
for (IEventHandler handler: handlers) {
handler.handleEvent(evt, sender, oldValue, newValue);
}
@@ -400,7 +392,7 @@
* @see org.tinytim.IEventPublisher#subscribe(org.tinytim.Event, org.tinytim.IEventHandler)
*/
public void subscribe(Event event, IEventHandler handler) {
- List<IEventHandler> handlers = _evtHandlers.get(event);
+ Collection<IEventHandler> handlers = _evtHandlers.get(event);
if (handlers == null) {
handlers = CollectionFactory.createList();
_evtHandlers.put(event, handlers);
@@ -409,15 +401,18 @@
}
/* (non-Javadoc)
- * @see org.tinytim.IEventPublisher#unsubscribe(org.tinytim.Event, org.tinytim.IEventHandler)
+ * @see org.tinytim.internal.api.IEventPublisher#unsubscribe(org.tinytim.internal.api.Event, org.tinytim.internal.api.IEventHandler)
*/
public void unsubscribe(Event event, IEventHandler handler) {
- List<IEventHandler> handlers = _evtHandlers.get(event);
+ Collection<IEventHandler> handlers = _evtHandlers.get(event);
if (handlers != null) {
handlers.remove(handler);
}
}
+ /* (non-Javadoc)
+ * @see org.tinytim.internal.api.IIndexManagerAware#getIndexManager()
+ */
public IIndexManager getIndexManager() {
return _indexManager;
}
Modified: tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMapSystem.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMapSystem.java 2008-11-13 18:10:28 UTC (rev 188)
+++ tinytim/trunk/src/main/java/org/tinytim/core/MemoryTopicMapSystem.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -64,7 +64,7 @@
}
/* (non-Javadoc)
- * @see org.tmapi.core.TopicMapSystem#getBaseLocators()
+ * @see org.tmapi.core.TopicMapSystem#getLocators()
*/
public Set<Locator> getLocators() {
return Collections.unmodifiableSet(_topicMaps.keySet());
Modified: tinytim/trunk/src/main/java/org/tinytim/core/NameImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/NameImpl.java 2008-11-13 18:10:28 UTC (rev 188)
+++ tinytim/trunk/src/main/java/org/tinytim/core/NameImpl.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -65,14 +65,14 @@
}
/* (non-Javadoc)
- * @see org.tinytim.core.ILiteralAware#getLiteral()
+ * @see org.tinytim.internal.api.ILiteralAware#getLiteral()
*/
public ILiteral getLiteral() {
return _literal;
}
/* (non-Javadoc)
- * @see org.tinytim.core.ILiteralAware#setLiteral(org.tinytim.core.ILiteral)
+ * @see org.tinytim.internal.api.ILiteralAware#setLiteral(org.tinytim.internal.api.ILiteral)
*/
public void setLiteral(ILiteral literal) {
assert literal != null;
@@ -81,7 +81,7 @@
}
/* (non-Javadoc)
- * @see org.tmapi.core.TopicName#getValue()
+ * @see org.tmapi.core.Name#getValue()
*/
public String getValue() {
return _literal.getValue();
@@ -128,7 +128,7 @@
}
/* (non-Javadoc)
- * @see org.tmapi.core.TopicName#getVariants()
+ * @see org.tmapi.core.Name#getVariants()
*/
public Set<Variant> getVariants() {
return _variants == null ? Collections.<Variant>emptySet()
@@ -214,30 +214,30 @@
attachVariant(v);
}
- void removeVariant(Variant variant) {
- VariantImpl v = (VariantImpl) variant;
- if (v._parent != this) {
- return;
- }
- _fireEvent(Event.REMOVE_VARIANT, v, null);
- detachVariant(v);
- }
+ void removeVariant(Variant variant) {
+ VariantImpl v = (VariantImpl) variant;
+ if (v._parent != this) {
+ return;
+ }
+ _fireEvent(Event.REMOVE_VARIANT, v, null);
+ detachVariant(v);
+ }
- void attachVariant(VariantImpl variant) {
- if (_variants == null) {
- _variants = CollectionFactory.createIdentitySet(IConstant.NAME_VARIANT_SIZE);
- }
- variant._parent = this;
- _variants.add(variant);
- }
+ void attachVariant(VariantImpl variant) {
+ if (_variants == null) {
+ _variants = CollectionFactory.createIdentitySet(IConstant.NAME_VARIANT_SIZE);
+ }
+ variant._parent = this;
+ _variants.add(variant);
+ }
- void detachVariant(VariantImpl variant) {
- _variants.remove(variant);
- variant._parent = null;
- }
+ void detachVariant(VariantImpl variant) {
+ _variants.remove(variant);
+ variant._parent = null;
+ }
/* (non-Javadoc)
- * @see org.tinytim.core.IMovable#moveTo(org.tmapi.core.Construct)
+ * @see org.tinytim.internal.api.IMovable#moveTo(org.tmapi.core.Construct)
*/
public void moveTo(Topic newParent) {
((TopicImpl) _parent).detachName(this, true);
Modified: tinytim/trunk/src/main/java/org/tinytim/core/OccurrenceImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/OccurrenceImpl.java 2008-11-13 18:10:28 UTC (rev 188)
+++ tinytim/trunk/src/main/java/org/tinytim/core/OccurrenceImpl.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -47,7 +47,7 @@
}
/* (non-Javadoc)
- * @see org.tinytim.IMovable#moveTo(java.lang.Object)
+ * @see org.tinytim.internal.api.IMovable#moveTo(org.tmapi.core.Construct)
*/
public void moveTo(Topic newParent) {
((TopicImpl) _parent).detachOccurrence(this, true);
Modified: tinytim/trunk/src/main/java/org/tinytim/core/Scope.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/Scope.java 2008-11-13 18:10:28 UTC (rev 188)
+++ tinytim/trunk/src/main/java/org/tinytim/core/Scope.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -84,7 +84,7 @@
}
/* (non-Javadoc)
- * @see org.tinytim.core.IScope#asSet()
+ * @see org.tinytim.internal.api.IScope#asSet()
*/
public Set<Topic> asSet() {
// _set is immutable
@@ -92,21 +92,21 @@
}
/* (non-Javadoc)
- * @see org.tinytim.core.IScope#contains(org.tmapi.core.Topic)
+ * @see org.tinytim.internal.api.IScope#contains(org.tmapi.core.Topic)
*/
public boolean contains(Topic theme) {
return _set.contains(theme);
}
/* (non-Javadoc)
- * @see org.tinytim.core.IScope#containsAll(java.util.Collection)
+ * @see org.tinytim.internal.api.IScope#containsAll(java.util.Collection)
*/
public boolean containsAll(Collection<Topic> scope) {
return _set.containsAll(scope);
}
/* (non-Javadoc)
- * @see org.tinytim.core.IScope#add(org.tmapi.core.Topic)
+ * @see org.tinytim.internal.api.IScope#add(org.tmapi.core.Topic)
*/
public IScope add(Topic theme) {
if (_set.contains(theme)) {
@@ -118,7 +118,7 @@
}
/* (non-Javadoc)
- * @see org.tinytim.core.IScope#remove(org.tmapi.core.Topic)
+ * @see org.tinytim.internal.api.IScope#remove(org.tmapi.core.Topic)
*/
public IScope remove(Topic theme) {
if (!_set.contains(theme)) {
@@ -137,14 +137,14 @@
}
/* (non-Javadoc)
- * @see org.tinytim.core.IScope#isUnconstrained()
+ * @see org.tinytim.internal.api.IScope#isUnconstrained()
*/
public boolean isUnconstrained() {
return this == UCS;
}
/* (non-Javadoc)
- * @see org.tinytim.core.IScope#size()
+ * @see org.tinytim.internal.api.IScope#size()
*/
public int size() {
return _set.size();
Modified: tinytim/trunk/src/main/java/org/tinytim/core/ScopedImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/ScopedImpl.java 2008-11-13 18:10:28 UTC (rev 188)
+++ tinytim/trunk/src/main/java/org/tinytim/core/ScopedImpl.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -49,14 +49,14 @@
}
/* (non-Javadoc)
- * @see org.tinytim.core.IScoped#getScopeObject()
+ * @see org.tinytim.internal.api.IScoped#getScopeObject()
*/
public IScope getScopeObject() {
return _scope;
}
/* (non-Javadoc)
- * @see org.tinytim.core.IScoped#setScopeObject(org.tinytim.core.IScope)
+ * @see org.tinytim.internal.api.IScoped#setScopeObject(org.tinytim.internal.api.IScope)
*/
public void setScopeObject(IScope scope) {
if (_scope == scope) {
@@ -67,14 +67,14 @@
}
/* (non-Javadoc)
- * @see org.tmapi.core.ScopedObject#getScope()
+ * @see org.tmapi.core.Scoped#getScope()
*/
public Set<Topic> getScope() {
return _scope.asSet();
}
/* (non-Javadoc)
- * @see org.tmapi.Scoped#removeTheme(org.tmapi.core.Topic)
+ * @see org.tmapi.core.Scoped#addTheme(org.tmapi.core.Topic)
*/
public void addTheme(Topic theme) {
if (theme == null) {
@@ -84,7 +84,7 @@
}
/* (non-Javadoc)
- * @see org.tmapi.Scoped#removeTheme(org.tmapi.core.Topic)
+ * @see org.tmapi.core.Scoped#removeTheme(org.tmapi.core.Topic)
*/
public void removeTheme(Topic theme) {
setScopeObject(_scope.remove(theme));
Modified: tinytim/trunk/src/main/java/org/tinytim/core/TopicImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/TopicImpl.java 2008-11-13 18:10:28 UTC (rev 188)
+++ tinytim/trunk/src/main/java/org/tinytim/core/TopicImpl.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -251,7 +251,7 @@
}
/* (non-Javadoc)
- * @see org.tmapi.core.Topic#getTopicNames()
+ * @see org.tmapi.core.Topic#getNames()
*/
public Set<Name> getNames() {
return Collections.unmodifiableSet(_names);
@@ -483,7 +483,7 @@
}
/* (non-Javadoc)
- * @see org.tmapi.core.TopicMapObject#remove()
+ * @see org.tmapi.core.Construct#remove()
*/
public void remove() throws TopicInUseException {
if (!TopicUtils.isRemovable(this, true)) {
@@ -492,7 +492,7 @@
if (_reified != null) {
_reified.setReifier(null);
}
- _tm.removeTopic(this);
+ ((AbstractTopicMap) _tm).removeTopic(this);
_sids.clear();
_slos = null;
_types = null;
@@ -523,5 +523,4 @@
return sb.toString();
}
-
}
Modified: tinytim/trunk/src/main/java/org/tinytim/core/TypedImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/TypedImpl.java 2008-11-13 18:10:28 UTC (rev 188)
+++ tinytim/trunk/src/main/java/org/tinytim/core/TypedImpl.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -54,8 +54,8 @@
return _type;
}
- /* (non-Javadoc)
- * @see org.tinytim.ITyped#setType(org.tmapi.core.Topic)
+ /*
+ * @see org.tmapi.core.Typed#setType(org.tmapi.core.Topic)
*/
public void setType(Topic type) {
Check.typeNotNull(this, type);
@@ -67,14 +67,14 @@
}
/* (non-Javadoc)
- * @see org.tmapi.core.IReifiable#getReifier()
+ * @see org.tmapi.core.Reifiable#getReifier()
*/
public Topic getReifier() {
return _reifier;
}
/* (non-Javadoc)
- * @see org.tinytim.IReifiable#setReifier(org.tmapi.core.Topic)
+ * @see org.tmapi.core.Reifiable#setReifier(org.tmapi.core.Topic)
*/
public void setReifier(Topic reifier) {
if (_reifier == reifier) {
@@ -91,7 +91,7 @@
}
/* (non-Javadoc)
- * @see org.tinytim.Construct#dispose()
+ * @see org.tinytim.core.ConstructImpl#dispose()
*/
@Override
protected void dispose() {
Modified: tinytim/trunk/src/main/java/org/tinytim/core/VariantImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/VariantImpl.java 2008-11-13 18:10:28 UTC (rev 188)
+++ tinytim/trunk/src/main/java/org/tinytim/core/VariantImpl.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -52,7 +52,7 @@
}
/* (non-Javadoc)
- * @see org.tinytim.IMovable#moveTo(java.lang.Object)
+ * @see org.tinytim.internal.api.IMovable#moveTo(org.tmapi.core.Construct)
*/
public void moveTo(Name newParent) {
((NameImpl) _parent).detachVariant(this);
Added: tinytim/trunk/src/main/java/org/tinytim/core/value/BooleanLiteral.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/value/BooleanLiteral.java (rev 0)
+++ tinytim/trunk/src/main/java/org/tinytim/core/value/BooleanLiteral.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2008 Lars Heuer (heuer[at]semagia.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.tinytim.core.value;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+import org.tinytim.internal.api.ILiteral;
+import org.tinytim.voc.XSD;
+import org.tmapi.core.Locator;
+
+/**
+ *
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+final class BooleanLiteral implements ILiteral {
+
+ public static final ILiteral TRUE = new BooleanLiteral(true);
+ public static final ILiteral FALSE = new BooleanLiteral(false);
+
+ private final boolean _value;
+
+ private BooleanLiteral(boolean value) {
+ _value = value;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.internal.api.ILiteral#decimalValue()
+ */
+ public BigDecimal decimalValue() {
+ return _value == true ? BigDecimal.ONE : BigDecimal.ZERO;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.internal.api.ILiteral#floatValue()
+ */
+ public float floatValue() {
+ return _value == true ? 1.0F : 0.0F;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.internal.api.ILiteral#getDatatype()
+ */
+ public Locator getDatatype() {
+ return XSD.BOOLEAN;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.internal.api.ILiteral#getValue()
+ */
+ public String getValue() {
+ return _value == true ? "true" : "false";
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.internal.api.ILiteral#intValue()
+ */
+ public int intValue() {
+ return _value == true ? 1 : 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.internal.api.ILiteral#integerValue()
+ */
+ public BigInteger integerValue() {
+ return _value == true ? BigInteger.ONE : BigInteger.ZERO;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.internal.api.ILiteral#longValue()
+ */
+ public long longValue() {
+ return intValue();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ return (obj instanceof BooleanLiteral) && _value == ((BooleanLiteral) obj)._value;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return _value == true ? 1 : 0;
+ }
+
+}
Property changes on: tinytim/trunk/src/main/java/org/tinytim/core/value/BooleanLiteral.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date Id
Added: svn:eol-style
+ native
Modified: tinytim/trunk/src/main/java/org/tinytim/core/value/DecimalLiteral.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/value/DecimalLiteral.java 2008-11-13 18:10:28 UTC (rev 188)
+++ tinytim/trunk/src/main/java/org/tinytim/core/value/DecimalLiteral.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -48,49 +48,49 @@
}
/* (non-Javadoc)
- * @see org.tinytim.core.ILiteral#decimalValue()
+ * @see org.tinytim.internal.api.ILiteral#decimalValue()
*/
public BigDecimal decimalValue() {
return _decimal;
}
/* (non-Javadoc)
- * @see org.tinytim.core.ILiteral#floatValue()
+ * @see org.tinytim.internal.api.ILiteral#floatValue()
*/
public float floatValue() {
return _decimal.floatValue();
}
/* (non-Javadoc)
- * @see org.tinytim.core.ILiteral#getDatatype()
+ * @see org.tinytim.internal.api.ILiteral#getDatatype()
*/
public Locator getDatatype() {
return XSD.DECIMAL;
}
/* (non-Javadoc)
- * @see org.tinytim.core.ILiteral#getValue()
+ * @see org.tinytim.internal.api.ILiteral#getValue()
*/
public String getValue() {
return _lexicalForm;
}
/* (non-Javadoc)
- * @see org.tinytim.core.ILiteral#intValue()
+ * @see org.tinytim.internal.api.ILiteral#intValue()
*/
public int intValue() {
return _decimal.intValue();
}
/* (non-Javadoc)
- * @see org.tinytim.core.ILiteral#integerValue()
+ * @see org.tinytim.internal.api.ILiteral#integerValue()
*/
public BigInteger integerValue() {
return _decimal.toBigInteger();
}
/* (non-Javadoc)
- * @see org.tinytim.core.ILiteral#longValue()
+ * @see org.tinytim.internal.api.ILiteral#longValue()
*/
public long longValue() {
return _decimal.longValue();
Modified: tinytim/trunk/src/main/java/org/tinytim/core/value/IntegerLiteral.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/value/IntegerLiteral.java 2008-11-13 18:10:28 UTC (rev 188)
+++ tinytim/trunk/src/main/java/org/tinytim/core/value/IntegerLiteral.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -49,7 +49,7 @@
}
/* (non-Javadoc)
- * @see org.tinytim.core.ILiteral#decimalValue()
+ * @see org.tinytim.internal.api.ILiteral#decimalValue()
*/
public BigDecimal decimalValue() {
if (_decimal == null) {
@@ -59,42 +59,42 @@
}
/* (non-Javadoc)
- * @see org.tinytim.core.ILiteral#floatValue()
+ * @see org.tinytim.internal.api.ILiteral#floatValue()
*/
public float floatValue() {
return _integer.floatValue();
}
/* (non-Javadoc)
- * @see org.tinytim.core.ILiteral#getDatatype()
+ * @see org.tinytim.internal.api.ILiteral#getDatatype()
*/
public Locator getDatatype() {
return XSD.INTEGER;
}
/* (non-Javadoc)
- * @see org.tinytim.core.ILiteral#getValue()
+ * @see org.tinytim.internal.api.ILiteral#getValue()
*/
public String getValue() {
return _lexicalForm;
}
/* (non-Javadoc)
- * @see org.tinytim.core.ILiteral#intValue()
+ * @see org.tinytim.internal.api.ILiteral#intValue()
*/
public int intValue() {
return _integer.intValue();
}
/* (non-Javadoc)
- * @see org.tinytim.core.ILiteral#integerValue()
+ * @see org.tinytim.internal.api.ILiteral#integerValue()
*/
public BigInteger integerValue() {
return _integer;
}
/* (non-Javadoc)
- * @see org.tinytim.core.ILiteral#longValue()
+ * @see org.tinytim.internal.api.ILiteral#longValue()
*/
public long longValue() {
return _integer.longValue();
Modified: tinytim/trunk/src/main/java/org/tinytim/core/value/Literal.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/value/Literal.java 2008-11-13 18:10:28 UTC (rev 188)
+++ tinytim/trunk/src/main/java/org/tinytim/core/value/Literal.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -23,6 +23,7 @@
import org.tinytim.internal.api.ILocator;
import org.tinytim.internal.utils.WeakObjectRegistry;
import org.tinytim.voc.XSD;
+import static org.tinytim.core.value.LiteralNormalizer.normalizeBoolean;
import org.tmapi.core.Locator;
@@ -53,14 +54,14 @@
}
/* (non-Javadoc)
- * @see org.tinytim.core.ILiteral#getDatatype()
+ * @see org.tinytim.internal.api.ILiteral#getDatatype()
*/
public Locator getDatatype() {
return _datatype;
}
/* (non-Javadoc)
- * @see org.tinytim.core.ILiteral#getValue()
+ * @see org.tinytim.internal.api.ILiteral#getValue()
*/
public String getValue() {
return _value;
@@ -90,6 +91,10 @@
if (XSD.STRING.equals(datatype)) {
return get(value);
}
+ if (XSD.BOOLEAN.equals(datatype)) {
+ return normalizeBoolean(value).equals("true") ? BooleanLiteral.TRUE
+ : BooleanLiteral.FALSE;
+ }
return _OTHERS.get(new Literal(value, datatype));
}
@@ -122,6 +127,9 @@
if (XSD.INTEGER.equals(datatype)) {
return createInteger(value);
}
+ if (XSD.BOOLEAN.equals(datatype)) {
+ return createBoolean(value);
+ }
return _registerIfAbsent(_OTHERS, new Literal(value, datatype));
}
@@ -191,6 +199,11 @@
return _registerIfAbsent(_OTHERS, new IntegerLiteral(value));
}
+ public static ILiteral createBoolean(String value) {
+ return normalizeBoolean(value).equals("true") ? BooleanLiteral.TRUE
+ : BooleanLiteral.FALSE;
+ }
+
public BigDecimal decimalValue() {
return new BigDecimal(_value);
}
@@ -211,11 +224,17 @@
return Long.valueOf(_value);
}
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
@Override
public int hashCode() {
return _value.hashCode();
}
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
@Override
public boolean equals(Object obj) {
if (this == obj) {
Modified: tinytim/trunk/src/main/java/org/tinytim/core/value/LiteralNormalizer.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/value/LiteralNormalizer.java 2008-11-13 18:10:28 UTC (rev 188)
+++ tinytim/trunk/src/main/java/org/tinytim/core/value/LiteralNormalizer.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -42,15 +42,15 @@
* @return A normalized value.
*/
public static String normalize(final String value, final Locator datatype) {
- if (XSD.BOOLEAN.equals(datatype)) {
- return normalizeBoolean(value);
- }
- else if (XSD.INTEGER.equals(datatype)) {
+ if (XSD.INTEGER.equals(datatype)) {
return normalizeInteger(value);
}
else if (XSD.DECIMAL.equals(datatype)) {
return normalizeDecimal(value);
}
+ else if (XSD.BOOLEAN.equals(datatype)) {
+ return normalizeBoolean(value);
+ }
return value;
}
Modified: tinytim/trunk/src/main/java/org/tinytim/core/value/LocatorImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/value/LocatorImpl.java 2008-11-13 18:10:28 UTC (rev 188)
+++ tinytim/trunk/src/main/java/org/tinytim/core/value/LocatorImpl.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -68,35 +68,50 @@
}
/* (non-Javadoc)
- * @see org.tinytim.core.ILiteral#getDatatype()
+ * @see org.tinytim.internal.api.ILiteral#getDatatype()
*/
public Locator getDatatype() {
return XSD.ANY_URI;
}
/* (non-Javadoc)
- * @see org.tinytim.core.ILiteral#getValue()
+ * @see org.tinytim.internal.api.ILiteral#getValue()
*/
public String getValue() {
return _reference;
}
+ /* (non-Javadoc)
+ * @see org.tinytim.internal.api.ILiteral#decimalValue()
+ */
public BigDecimal decimalValue() {
throw new NumberFormatException();
}
+ /* (non-Javadoc)
+ * @see org.tinytim.internal.api.ILiteral#floatValue()
+ */
public float floatValue() {
throw new NumberFormatException();
}
+ /* (non-Javadoc)
+ * @see org.tinytim.internal.api.ILiteral#integerValue()
+ */
public BigInteger integerValue() {
throw new NumberFormatException();
}
+ /* (non-Javadoc)
+ * @see org.tinytim.internal.api.ILiteral#intValue()
+ */
public int intValue() {
throw new NumberFormatException();
}
+ /* (non-Javadoc)
+ * @see org.tinytim.internal.api.ILiteral#longValue()
+ */
public long longValue() {
throw new NumberFormatException();
}
Modified: tinytim/trunk/src/main/java/org/tinytim/index/AbstractIndex.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/AbstractIndex.java 2008-11-13 18:10:28 UTC (rev 188)
+++ tinytim/trunk/src/main/java/org/tinytim/index/AbstractIndex.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -20,8 +20,7 @@
import org.tmapi.index.Index;
/**
- * Abstract base class for {@link org.tmapi.index.Index} implementation which
- * are autoupdated.
+ * Abstract base class for {@link Index} implementations which are autoupdated.
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
* @version $Rev$ - $Date$
@@ -70,4 +69,9 @@
// noop.
}
+ /**
+ * Clears the index.
+ */
+ abstract void clear();
+
}
Deleted: tinytim/trunk/src/main/java/org/tinytim/index/IIndexManager.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/IIndexManager.java 2008-11-13 18:10:28 UTC (rev 188)
+++ tinytim/trunk/src/main/java/org/tinytim/index/IIndexManager.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -1,57 +0,0 @@
-/*
- * Copyright 2008 Lars Heuer (heuer[at]semagia.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.tinytim.index;
-
-import org.tinytim.internal.api.IEventPublisherAware;
-import org.tmapi.index.LiteralIndex;
-import org.tmapi.index.ScopedIndex;
-import org.tmapi.index.TypeInstanceIndex;
-
-/**
- * The index manager provides access to the tinyTiM-specific indexes.
- *
- * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev$ - $Date$
- */
-public interface IIndexManager extends IEventPublisherAware {
-
- /**
- * Returns the {@link TypeInstanceIndex}.
- *
- * @return A {@link TypeInstanceIndex} instance.
- */
- public TypeInstanceIndex getTypeInstanceIndex();
-
- /**
- * Returns the {@link ScopedIndex}.
- *
- * @return A {@link ScopedIndex} instance.
- */
- public ScopedIndex getScopedIndex();
-
- /**
- * Returns the {@link LiteralIndex}.
- *
- * @return A {@link LiteralIndex} instance.
- */
- public LiteralIndex getLiteralIndex();
-
- /**
- * Closes this index manager.
- */
- public void close();
-
-}
Modified: tinytim/trunk/src/main/java/org/tinytim/index/IndexManager.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/IndexManager.java 2008-11-13 18:10:28 UTC (rev 188)
+++ tinytim/trunk/src/main/java/org/tinytim/index/IndexManager.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -16,6 +16,8 @@
package org.tinytim.index;
import org.tinytim.internal.api.IEventPublisher;
+import org.tinytim.internal.api.IIndexManager;
+
import org.tmapi.index.LiteralIndex;
import org.tmapi.index.ScopedIndex;
import org.tmapi.index.TypeInstanceIndex;
@@ -40,7 +42,7 @@
}
/* (non-Javadoc)
- * @see org.tinytim.core.IEventPublisherAware#subscribe(org.tinytim.core.IEventPublisher)
+ * @see org.tinytim.internal.api.IEventPublisherAware#subscribe(org.tinytim.internal.api.IEventPublisher)
*/
public void subscribe(final IEventPublisher publisher) {
_typeInstanceIndex.subscribe(publisher);
@@ -49,7 +51,7 @@
}
/* (non-Javadoc)
- * @see org.tinytim.core.IEventPublisherAware#unsubscribe(org.tinytim.core.IEventPublisher)
+ * @see org.tinytim.internal.api.IEventPublisherAware#unsubscribe(org.tinytim.internal.api.IEventPublisher)
*/
public void unsubscribe(IEventPublisher publisher) {
_typeInstanceIndex.unsubscribe(publisher);
@@ -58,26 +60,29 @@
}
/* (non-Javadoc)
- * @see org.tinytim.index.IIndexManager#getTypeInstanceIndex()
+ * @see org.tinytim.internal.api.IIndexManager#getTypeInstanceIndex()
*/
public TypeInstanceIndex getTypeInstanceIndex() {
return _typeInstanceIndex;
}
/* (non-Javadoc)
- * @see org.tinytim.index.IIndexManager#getScopedIndex()
+ * @see org.tinytim.internal.api.IIndexManager#getScopedIndex()
*/
public ScopedIndex getScopedIndex() {
return _scopedIndex;
}
/* (non-Javadoc)
- * @see org.tinytim.index.IIndexManager#getLiteralIndex()
+ * @see org.tinytim.internal.api.IIndexManager#getLiteralIndex()
*/
public LiteralIndex getLiteralIndex() {
return _literalIndex;
}
+ /* (non-Javadoc)
+ * @see org.tinytim.internal.api.IIndexManager#close()
+ */
public void close() {
_typeInstanceIndex.clear();
_scopedIndex.clear();
Modified: tinytim/trunk/src/main/java/org/tinytim/index/LiteralIndexImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/LiteralIndexImpl.java 2008-11-13 18:10:28 UTC (rev 188)
+++ tinytim/trunk/src/main/java/org/tinytim/index/LiteralIndexImpl.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -42,21 +42,21 @@
*/
public class LiteralIndexImpl extends AbstractIndex implements LiteralIndex {
- private Map<ILiteral, List<Name>> _lit2Names;
- private Map<ILiteral, List<Occurrence>> _lit2Occs;
- private Map<ILiteral, List<Variant>> _lit2Variants;
+ private final Map<ILiteral, List<Name>> _lit2Names;
+ private final Map<ILiteral, List<Occurrence>> _lit2Occs;
+ private final Map<ILiteral, List<Variant>> _lit2Variants;
public LiteralIndexImpl() {
super();
+ _lit2Names = CollectionFactory.createIdentityMap();
+ _lit2Occs = CollectionFactory.createIdentityMap();
+ _lit2Variants = CollectionFactory.createIdentityMap();
}
/* (non-Javadoc)
- * @see org.tinytim.core.IEventPublisherAware#subscribe(org.tinytim.core.IEventPublisher)
+ * @see org.tinytim.internal.api.IEventPublisherAware#subscribe(org.tinytim.internal.api.IEventPublisher)
*/
public void subscribe(IEventPublisher publisher) {
- _lit2Names = CollectionFactory.createIdentityMap();
- _lit2Occs = CollectionFactory.createIdentityMap();
- _lit2Variants = CollectionFactory.createIdentityMap();
publisher.subscribe(Event.SET_LITERAL, new LiteralHandler());
IEventHandler handler = new AddLiteralAwareHandler();
publisher.subscribe(Event.ATTACHED_OCCURRENCE, handler);
@@ -75,6 +75,12 @@
return _getNames(Literal.get(value));
}
+ /**
+ *
+ *
+ * @param literal
+ * @return
+ */
private Collection<Name> _getNames(ILiteral literal) {
if (literal == null) {
return Collections.<Name>emptySet();
@@ -108,6 +114,12 @@
return _getOccurrences(Literal.get(value, datatype));
}
+ /**
+ *
+ *
+ * @param literal
+ * @return
+ */
private Collection<Occurrence> _getOccurrences(ILiteral literal) {
if (literal == null) {
return Collections.<Occurrence>emptySet();
@@ -141,6 +153,12 @@
return _getVariants(Literal.get(value, datatype));
}
+ /**
+ *
+ *
+ * @param literal
+ * @return
+ */
private Collection<Variant> _getVariants(ILiteral literal) {
if (literal == null) {
return Collections.<Variant>emptySet();
@@ -150,6 +168,9 @@
: CollectionFactory.createList(variants);
}
+ /* (non-Javadoc)
+ * @see org.tinytim.index.AbstractIndex#clear()
+ */
public void clear() {
_lit2Names.clear();
_lit2Occs.clear();
Modified: tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndexImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndexImpl.java 2008-11-13 18:10:28 UTC (rev 188)
+++ tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndexImpl.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -44,23 +44,23 @@
*/
public class ScopedIndexImpl extends AbstractIndex implements ScopedIndex {
- private Map<Topic, Set<Association>> _theme2Assocs;
- private Map<Topic, Set<Occurrence>> _theme2Occs;
- private Map<Topic, Set<Name>> _theme2Names;
- private Map<Topic, Set<Variant>> _theme2Variants;
+ private final Map<Topic, Set<Association>> _theme2Assocs;
+ private final Map<Topic, Set<Occurrence>> _theme2Occs;
+ private final Map<Topic, Set<Name>> _theme2Names;
+ private final Map<Topic, Set<Variant>> _theme2Variants;
public ScopedIndexImpl() {
super();
+ _theme2Assocs = CollectionFactory.createIdentityMap();
+ _theme2Occs = CollectionFactory.createIdentityMap();
+ _theme2Names = CollectionFactory.createIdentityMap();
+ _theme2Variants = CollectionFactory.createIdentityMap();
}
/* (non-Javadoc)
* @see org.tinytim.core.IEventPublisherAware#subscribe(org.tinytim.core.IEventPublisher)
*/
public void subscribe(IEventPublisher publisher) {
- _theme2Assocs = CollectionFactory.createIdentityMap();
- _theme2Occs = CollectionFactory.createIdentityMap();
- _theme2Names = CollectionFactory.createIdentityMap();
- _theme2Variants = CollectionFactory.createIdentityMap();
publisher.subscribe(Event.SET_SCOPE, new SetScopeHandler());
IEventHandler handler = new AddScopedHandler();
publisher.subscribe(Event.ADD_ASSOCIATION, handler);
@@ -239,15 +239,14 @@
return themes;
}
+ /* (non-Javadoc)
+ * @see org.tinytim.index.AbstractIndex#clear()
+ */
void clear() {
_theme2Assocs.clear();
- _theme2Assocs = null;
_theme2Occs.clear();
- _theme2Occs = null;
_theme2Names.clear();
- _theme2Names = null;
_theme2Variants.clear();
- _theme2Variants = null;
}
private void _unindex(Map<Topic, Set<Scoped>> map, Scoped scoped, IScope scope) {
Modified: tinytim/trunk/src/main/java/org/tinytim/index/TypeInstanceIndexImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/TypeInstanceIndexImpl.java 2008-11-13 18:10:28 UTC (rev 188)
+++ tinytim/trunk/src/main/java/org/tinytim/index/TypeInstanceIndexImpl.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -42,25 +42,25 @@
*/
public class TypeInstanceIndexImpl extends AbstractIndex implements TypeInstanceIndex {
- private Map<Topic, Set<Topic>> _type2Topics;
- private Map<Topic, List<Association>> _type2Assocs;
- private Map<Topic, List<Role>> _type2Roles;
- private Map<Topic, List<Occurrence>> _type2Occs;
- private Map<Topic, List<Name>> _type2Names;
+ private final Map<Topic, Set<Topic>> _type2Topics;
+ private final Map<Topic, List<Association>> _type2Assocs;
+ private final Map<Topic, List<Role>> _type2Roles;
+ private final Map<Topic, List<Occurrence>> _type2Occs;
+ private final Map<Topic, List<Name>> _type2Names;
public TypeInstanceIndexImpl() {
super();
+ _type2Topics = CollectionFactory.createIdentityMap();
+ _type2Assocs = CollectionFactory.createIdentityMap();
+ _type2Roles = CollectionFactory.createIdentityMap();
+ _type2Occs = CollectionFactory.createIdentityMap();
+ _type2Names = CollectionFactory.createIdentityMap();
}
/* (non-Javadoc)
* @see org.tinytim.core.IEventPublisherAware#subscribe(org.tinytim.core.IEventPublisher)
*/
public void subscribe(IEventPublisher publisher) {
- _type2Topics = CollectionFactory.createIdentityMap();
- _type2Assocs = CollectionFactory.createIdentityMap();
- _type2Roles = CollectionFactory.createIdentityMap();
- _type2Occs = CollectionFactory.createIdentityMap();
- _type2Names = CollectionFactory.createIdentityMap();
IEventHandler handler = new TopicTypeHandler();
publisher.subscribe(Event.ADD_TYPE, handler);
publisher.subscribe(Event.REMOVE_TYPE, handler);
@@ -352,16 +352,14 @@
}
}
+ /* (non-Javadoc)
+ * @see org.tinytim.index.AbstractIndex#clear()
+ */
void clear() {
_type2Topics.clear();
- _type2Topics = null;
_type2Assocs.clear();
- _type2Assocs = null;
_type2Roles.clear();
- _type2Roles = null;
_type2Occs.clear();
- _type2Occs = null;
_type2Names.clear();
- _type2Names = null;
}
}
Modified: tinytim/trunk/src/main/java/org/tinytim/internal/api/IConstant.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/internal/api/IConstant.java 2008-11-13 18:10:28 UTC (rev 188)
+++ tinytim/trunk/src/main/java/org/tinytim/internal/api/IConstant.java 2008-11-14 13:35:18 UTC (rev 189)
@@ -26,83 +26,83 @@
*/
public interface IConstant {
/**
- * Initial size of the {@link MemoryTopicMap} topic set
+ * Initial size of the topic set
*/
public static final int TM_TOPIC_SIZE = 100;
/**
- * Initial size of the {@link MemoryTopicMap} association set
+ * Initial size of the association set
*/
public static final int TM_ASSOCIATION_SIZE = 100;
/**
- * Initial size of the {@link ConstructImpl} item identifier set.
+ * Initial size of the item identifier set.
*/
public static final int CONSTRUCT_IID_SIZE = 4;
/**
- * Initial size of the {@link TopicImpl} subject identifier set.
+ * Initial size of the subject identifier set.
*/
public static final int TOPIC_SID_SIZE = 4;
/**
- * Initial size of the {@link TopicImpl} subject locator set.
+ * Initial size of the subject locator set.
*/
public static final int TOPIC_SLO_SIZE = 2;
/**
- * Initial size of the {@link TopicImpl} types set.
+ * Initial size of the topic types set.
*/
public static final int TOPIC_TYPE_SIZE = 2;
/**
- * Initial size of the {@link TopicImpl} name set.
+ * Initial size of the name set.
*/
public static final int TOPIC_NAME_SIZE = 2;
/**
- * Initial size of the {@link TopicImpl} occurrence set.
+ * Initial size of the occurrence set.
*/
public static final int TOPIC_OCCURRENCE_SIZE = 2;
/**
- * Initial size ...
[truncated message content] |