From: <lh...@us...> - 2008-08-19 12:01:52
|
Revision: 134 http://tinytim.svn.sourceforge.net/tinytim/?rev=134&view=rev Author: lheuer Date: 2008-08-19 12:02:01 +0000 (Tue, 19 Aug 2008) Log Message: ----------- - Updated Scope handling for Variants. The solution sucks but passes the TMAPI tests. Anyway, better solution needed Modified Paths: -------------- tinytim/trunk/src/main/java/org/tinytim/core/NameImpl.java tinytim/trunk/src/main/java/org/tinytim/core/ScopedImpl.java tinytim/trunk/src/main/java/org/tinytim/core/VariantImpl.java Modified: tinytim/trunk/src/main/java/org/tinytim/core/NameImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/NameImpl.java 2008-08-17 18:49:30 UTC (rev 133) +++ tinytim/trunk/src/main/java/org/tinytim/core/NameImpl.java 2008-08-19 12:02:01 UTC (rev 134) @@ -98,10 +98,13 @@ */ @Override public void addTheme(Topic theme) { + IScope scope = _scope; super.addTheme(theme); - if (_variants != null) { - for (Variant variant: _variants) { - variant.addTheme(theme); + if (scope != _scope) { + if (_variants != null) { + for (Variant variant: _variants) { + ((VariantImpl) variant)._addNameTheme(theme); + } } } } @@ -111,10 +114,13 @@ */ @Override public void removeTheme(Topic theme) { + IScope scope = _scope; super.removeTheme(theme); - if (_variants != null) { - for (Variant variant: _variants) { - variant.removeTheme(theme); + if (scope != _scope) { + if (_variants != null) { + for (Variant variant: _variants) { + ((VariantImpl) variant)._removeNameTheme(theme); + } } } } @@ -185,15 +191,14 @@ if (scope.isEmpty()) { throw new ModelConstraintException(this, "The scope of the variant must not be unconstrained"); } - Set<Topic> nameScope = super.getScope(); - if (nameScope.containsAll(scope)) { + if (_scope.containsAll(scope)) { throw new ModelConstraintException(this, "The variant's scope is not a true superset of the parent's scope"); } - Set<Topic> scope_ = CollectionFactory.createIdentitySet(scope.size() + nameScope.size()); - scope_.addAll(scope); - scope_.addAll(nameScope); - Variant variant = new VariantImpl(_tm, literal, Scope.create(scope_)); + VariantImpl variant = new VariantImpl(_tm, literal, Scope.create(scope)); addVariant(variant); + for (Topic theme: _scope) { + variant._addNameTheme(theme); + } return variant; } Modified: tinytim/trunk/src/main/java/org/tinytim/core/ScopedImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/ScopedImpl.java 2008-08-17 18:49:30 UTC (rev 133) +++ tinytim/trunk/src/main/java/org/tinytim/core/ScopedImpl.java 2008-08-19 12:02:01 UTC (rev 134) @@ -36,7 +36,7 @@ //NOTE: This class does NOT implement IScoped by intention! - private IScope _scope; + protected IScope _scope; ScopedImpl(TopicMapImpl tm) { super(tm); Modified: tinytim/trunk/src/main/java/org/tinytim/core/VariantImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/VariantImpl.java 2008-08-17 18:49:30 UTC (rev 133) +++ tinytim/trunk/src/main/java/org/tinytim/core/VariantImpl.java 2008-08-19 12:02:01 UTC (rev 134) @@ -20,7 +20,11 @@ */ package org.tinytim.core; +import java.util.Set; + +import org.tinytim.internal.utils.CollectionFactory; import org.tmapi.core.Name; +import org.tmapi.core.Topic; import org.tmapi.core.Variant; /** @@ -72,4 +76,25 @@ super.dispose(); } + /* (non-Javadoc) + * @see org.tinytim.core.ScopedImpl#getScope() + */ + @Override + public Set<Topic> getScope() { + Set<Topic> scope = CollectionFactory.createIdentitySet(getParent().getScope()); + scope.addAll(_scope.asSet()); + return scope; + } + + void _addNameTheme(Topic theme) { + if (!_scope.contains(theme)) { + _fireEvent(Event.SET_SCOPE, _scope, _scope.add(theme)); + } + } + + void _removeNameTheme(Topic theme) { + IScope scope = Scope.create(getScope()); + _fireEvent(Event.SET_SCOPE, scope.add(theme), scope); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-09-05 12:01:33
|
Revision: 156 http://tinytim.svn.sourceforge.net/tinytim/?rev=156&view=rev Author: lheuer Date: 2008-09-05 12:01:41 +0000 (Fri, 05 Sep 2008) Log Message: ----------- Added dedicated DecimalLiteral and IntegerLiteral Modified Paths: -------------- tinytim/trunk/src/main/java/org/tinytim/core/Literal.java Added Paths: ----------- tinytim/trunk/src/main/java/org/tinytim/core/DecimalLiteral.java tinytim/trunk/src/main/java/org/tinytim/core/IntegerLiteral.java Added: tinytim/trunk/src/main/java/org/tinytim/core/DecimalLiteral.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/DecimalLiteral.java (rev 0) +++ tinytim/trunk/src/main/java/org/tinytim/core/DecimalLiteral.java 2008-09-05 12:01:41 UTC (rev 156) @@ -0,0 +1,115 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim.core; + +import java.math.BigDecimal; +import java.math.BigInteger; + +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 DecimalLiteral implements ILiteral { + + private final BigDecimal _decimal; + private final String _lexicalForm; + + public DecimalLiteral(BigDecimal decimal) { + _decimal = decimal; + _lexicalForm = LiteralNormalizer.normalizeDecimal(decimal.toPlainString()); + } + + public DecimalLiteral(String value) { + _lexicalForm = LiteralNormalizer.normalizeDecimal(value); + _decimal = new BigDecimal(_lexicalForm); + } + + /* (non-Javadoc) + * @see org.tinytim.core.ILiteral#decimalValue() + */ + public BigDecimal decimalValue() { + return _decimal; + } + + /* (non-Javadoc) + * @see org.tinytim.core.ILiteral#floatValue() + */ + public float floatValue() { + return _decimal.floatValue(); + } + + /* (non-Javadoc) + * @see org.tinytim.core.ILiteral#getDatatype() + */ + public Locator getDatatype() { + return XSD.DECIMAL; + } + + /* (non-Javadoc) + * @see org.tinytim.core.ILiteral#getValue() + */ + public String getValue() { + return _lexicalForm; + } + + /* (non-Javadoc) + * @see org.tinytim.core.ILiteral#intValue() + */ + public int intValue() { + return _decimal.intValue(); + } + + /* (non-Javadoc) + * @see org.tinytim.core.ILiteral#integerValue() + */ + public BigInteger integerValue() { + return _decimal.toBigInteger(); + } + + /* (non-Javadoc) + * @see org.tinytim.core.ILiteral#longValue() + */ + public long longValue() { + return _decimal.longValue(); + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return _decimal.hashCode(); + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + return this == obj || (obj instanceof DecimalLiteral) && ((DecimalLiteral) obj)._lexicalForm.equals(_lexicalForm); + } + +} Property changes on: tinytim/trunk/src/main/java/org/tinytim/core/DecimalLiteral.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Added: tinytim/trunk/src/main/java/org/tinytim/core/IntegerLiteral.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IntegerLiteral.java (rev 0) +++ tinytim/trunk/src/main/java/org/tinytim/core/IntegerLiteral.java 2008-09-05 12:01:41 UTC (rev 156) @@ -0,0 +1,119 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim.core; + +import java.math.BigDecimal; +import java.math.BigInteger; + +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 IntegerLiteral implements ILiteral { + + private final BigInteger _integer; + private final String _lexicalForm; + private BigDecimal _decimal; + + public IntegerLiteral(BigInteger value) { + _integer = value; + _lexicalForm = LiteralNormalizer.normalizeInteger(value.toString()); + } + + public IntegerLiteral(String value) { + _lexicalForm = LiteralNormalizer.normalizeInteger(value); + _integer = new BigInteger(_lexicalForm); + } + + /* (non-Javadoc) + * @see org.tinytim.core.ILiteral#decimalValue() + */ + public BigDecimal decimalValue() { + if (_decimal == null) { + _decimal = new BigDecimal(_integer); + } + return _decimal; + } + + /* (non-Javadoc) + * @see org.tinytim.core.ILiteral#floatValue() + */ + public float floatValue() { + return _integer.floatValue(); + } + + /* (non-Javadoc) + * @see org.tinytim.core.ILiteral#getDatatype() + */ + public Locator getDatatype() { + return XSD.INTEGER; + } + + /* (non-Javadoc) + * @see org.tinytim.core.ILiteral#getValue() + */ + public String getValue() { + return _lexicalForm; + } + + /* (non-Javadoc) + * @see org.tinytim.core.ILiteral#intValue() + */ + public int intValue() { + return _integer.intValue(); + } + + /* (non-Javadoc) + * @see org.tinytim.core.ILiteral#integerValue() + */ + public BigInteger integerValue() { + return _integer; + } + + /* (non-Javadoc) + * @see org.tinytim.core.ILiteral#longValue() + */ + public long longValue() { + return _integer.longValue(); + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return _integer.hashCode(); + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + return this == obj || (obj instanceof IntegerLiteral) && ((IntegerLiteral) obj)._lexicalForm.equals(_lexicalForm); + } + +} Property changes on: tinytim/trunk/src/main/java/org/tinytim/core/IntegerLiteral.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Modified: tinytim/trunk/src/main/java/org/tinytim/core/Literal.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/Literal.java 2008-09-04 13:28:44 UTC (rev 155) +++ tinytim/trunk/src/main/java/org/tinytim/core/Literal.java 2008-09-05 12:01:41 UTC (rev 156) @@ -107,6 +107,12 @@ if (XSD.STRING.equals(datatype)) { return create(value); } + if (XSD.DECIMAL.equals(datatype)) { + return createDecimal(value); + } + if (XSD.INTEGER.equals(datatype)) { + return createInteger(value); + } ILiteral literal = new Literal(value, datatype); ILiteral existing = _OTHERS.get(literal); if (existing != null) { @@ -127,11 +133,11 @@ } public static ILiteral create(BigDecimal value) { - return create(value, XSD.DECIMAL); + return createDecimal(value); } public static ILiteral create(BigInteger value) { - return create(value, XSD.INTEGER); + return createInteger(value); } public static ILiteral create(float value) { @@ -174,6 +180,58 @@ return iri; } + public static synchronized ILiteral createDecimal(String value) { + if (value == null) { + throw new IllegalArgumentException("The value must not be null"); + } + ILiteral lit = new DecimalLiteral(value); + ILiteral existing = _OTHERS.get(lit); + if (existing != null) { + return existing; + } + _OTHERS.add(lit); + return lit; + } + + public static synchronized ILiteral createDecimal(BigDecimal value) { + if (value == null) { + throw new IllegalArgumentException("The value must not be null"); + } + ILiteral lit = new DecimalLiteral(value); + ILiteral existing = _OTHERS.get(lit); + if (existing != null) { + return existing; + } + _OTHERS.add(lit); + return lit; + } + + public static synchronized ILiteral createInteger(String value) { + if (value == null) { + throw new IllegalArgumentException("The value must not be null"); + } + ILiteral lit = new IntegerLiteral(value); + ILiteral existing = _OTHERS.get(lit); + if (existing != null) { + return existing; + } + _OTHERS.add(lit); + return lit; + } + + public static synchronized ILiteral createInteger(BigInteger value) { + if (value == null) { + throw new IllegalArgumentException("The value must not be null"); + } + ILiteral lit = new IntegerLiteral(value); + ILiteral existing = _OTHERS.get(lit); + if (existing != null) { + return existing; + } + _OTHERS.add(lit); + return lit; + } + public BigDecimal decimalValue() { return new BigDecimal(_value); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-09-08 11:37:44
|
Revision: 157 http://tinytim.svn.sourceforge.net/tinytim/?rev=157&view=rev Author: lheuer Date: 2008-09-08 11:37:54 +0000 (Mon, 08 Sep 2008) Log Message: ----------- * Simplified Literal factory methods * DatatypeAwareConstruct uses createDecimal / createInteger directly Modified Paths: -------------- tinytim/trunk/src/main/java/org/tinytim/core/DatatypeAwareConstruct.java tinytim/trunk/src/main/java/org/tinytim/core/Literal.java Modified: tinytim/trunk/src/main/java/org/tinytim/core/DatatypeAwareConstruct.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/DatatypeAwareConstruct.java 2008-09-05 12:01:41 UTC (rev 156) +++ tinytim/trunk/src/main/java/org/tinytim/core/DatatypeAwareConstruct.java 2008-09-08 11:37:54 UTC (rev 157) @@ -92,7 +92,7 @@ */ public void setValue(BigDecimal value) { Check.valueNotNull(this, value); - setLiteral(Literal.create(value)); + setLiteral(Literal.createDecimal(value)); } /* (non-Javadoc) @@ -100,7 +100,7 @@ */ public void setValue(BigInteger value) { Check.valueNotNull(this, value); - setLiteral(Literal.create(value)); + setLiteral(Literal.createInteger(value)); } /* (non-Javadoc) Modified: tinytim/trunk/src/main/java/org/tinytim/core/Literal.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/Literal.java 2008-09-05 12:01:41 UTC (rev 156) +++ tinytim/trunk/src/main/java/org/tinytim/core/Literal.java 2008-09-08 11:37:54 UTC (rev 157) @@ -94,6 +94,15 @@ } + private static synchronized <L extends ILiteral> L _registerIfAbsent(final WeakObjectRegistry<L> registry, final L lit) { + final L existing = registry.get(lit); + if (existing != null) { + return existing; + } + registry.add(lit); + return lit; + } + public static synchronized ILiteral create(final String value, final Locator datatype) { if (value == null) { throw new IllegalArgumentException("The value must not be null"); @@ -113,33 +122,13 @@ if (XSD.INTEGER.equals(datatype)) { return createInteger(value); } - ILiteral literal = new Literal(value, datatype); - ILiteral existing = _OTHERS.get(literal); - if (existing != null) { - return existing; - } - _OTHERS.add(literal); - return literal; + return _registerIfAbsent(_OTHERS, new Literal(value, datatype)); } public static synchronized ILiteral create(String value) { - ILiteral literal = new Literal(value, XSD.STRING); - ILiteral existing = _STRINGS.get(literal); - if (existing != null) { - return existing; - } - _STRINGS.add(literal); - return literal; + return _registerIfAbsent(_STRINGS, new Literal(value, XSD.STRING)); } - public static ILiteral create(BigDecimal value) { - return createDecimal(value); - } - - public static ILiteral create(BigInteger value) { - return createInteger(value); - } - public static ILiteral create(float value) { return create(value, XSD.FLOAT); } @@ -171,65 +160,35 @@ if (value == null) { throw new IllegalArgumentException("The value must not be null"); } - IRI iri = new IRI(value); - IRI existing = _IRIS.get(iri); - if (existing != null) { - return existing; - } - _IRIS.add(iri); - return iri; + return _registerIfAbsent(_IRIS, new IRI(value)); } public static synchronized ILiteral createDecimal(String value) { if (value == null) { throw new IllegalArgumentException("The value must not be null"); } - ILiteral lit = new DecimalLiteral(value); - ILiteral existing = _OTHERS.get(lit); - if (existing != null) { - return existing; - } - _OTHERS.add(lit); - return lit; + return _registerIfAbsent(_OTHERS, new DecimalLiteral(value)); } public static synchronized ILiteral createDecimal(BigDecimal value) { if (value == null) { throw new IllegalArgumentException("The value must not be null"); } - ILiteral lit = new DecimalLiteral(value); - ILiteral existing = _OTHERS.get(lit); - if (existing != null) { - return existing; - } - _OTHERS.add(lit); - return lit; + return _registerIfAbsent(_OTHERS, new DecimalLiteral(value)); } public static synchronized ILiteral createInteger(String value) { if (value == null) { throw new IllegalArgumentException("The value must not be null"); } - ILiteral lit = new IntegerLiteral(value); - ILiteral existing = _OTHERS.get(lit); - if (existing != null) { - return existing; - } - _OTHERS.add(lit); - return lit; + return _registerIfAbsent(_OTHERS, new IntegerLiteral(value)); } public static synchronized ILiteral createInteger(BigInteger value) { if (value == null) { throw new IllegalArgumentException("The value must not be null"); } - ILiteral lit = new IntegerLiteral(value); - ILiteral existing = _OTHERS.get(lit); - if (existing != null) { - return existing; - } - _OTHERS.add(lit); - return lit; + return _registerIfAbsent(_OTHERS, new IntegerLiteral(value)); } public BigDecimal decimalValue() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-11-15 13:03:10
|
Revision: 197 http://tinytim.svn.sourceforge.net/tinytim/?rev=197&view=rev Author: lheuer Date: 2008-11-15 13:02:58 +0000 (Sat, 15 Nov 2008) Log Message: ----------- - Restricted constructor visibility of abstract classes to protected - Simplified theme handling for variants in NameImpl - Docs Modified Paths: -------------- tinytim/trunk/src/main/java/org/tinytim/core/AbstractTopicMap.java tinytim/trunk/src/main/java/org/tinytim/core/AbstractTopicMapSystem.java tinytim/trunk/src/main/java/org/tinytim/core/NameImpl.java tinytim/trunk/src/main/java/org/tinytim/core/ScopedImpl.java tinytim/trunk/src/main/java/org/tinytim/core/TypedImpl.java tinytim/trunk/src/main/java/org/tinytim/core/value/BooleanLiteral.java Modified: tinytim/trunk/src/main/java/org/tinytim/core/AbstractTopicMap.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/AbstractTopicMap.java 2008-11-14 15:51:56 UTC (rev 196) +++ tinytim/trunk/src/main/java/org/tinytim/core/AbstractTopicMap.java 2008-11-15 13:02:58 UTC (rev 197) @@ -23,7 +23,7 @@ * * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ abstract class AbstractTopicMap extends ConstructImpl implements ITopicMap { Modified: tinytim/trunk/src/main/java/org/tinytim/core/AbstractTopicMapSystem.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/AbstractTopicMapSystem.java 2008-11-14 15:51:56 UTC (rev 196) +++ tinytim/trunk/src/main/java/org/tinytim/core/AbstractTopicMapSystem.java 2008-11-15 13:02:58 UTC (rev 197) @@ -37,7 +37,7 @@ protected final Map<String, Boolean> _features; protected final Map<String, Object> _properties; - AbstractTopicMapSystem(Map<String, Boolean> features, Map<String, Object> properties) throws TMAPIException { + protected AbstractTopicMapSystem(Map<String, Boolean> features, Map<String, Object> properties) throws TMAPIException { _features = features; _properties = properties; } Modified: tinytim/trunk/src/main/java/org/tinytim/core/NameImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/NameImpl.java 2008-11-14 15:51:56 UTC (rev 196) +++ tinytim/trunk/src/main/java/org/tinytim/core/NameImpl.java 2008-11-15 13:02:58 UTC (rev 197) @@ -102,11 +102,9 @@ public void addTheme(Topic theme) { IScope scope = _scope; super.addTheme(theme); - if (scope != _scope) { - if (_variants != null) { - for (Variant variant: _variants) { - ((VariantImpl) variant)._addNameTheme(theme); - } + if (_variants != null && scope != _scope) { + for (Variant variant: _variants) { + ((VariantImpl) variant)._addNameTheme(theme); } } } @@ -118,11 +116,9 @@ public void removeTheme(Topic theme) { IScope scope = _scope; super.removeTheme(theme); - if (scope != _scope) { - if (_variants != null) { - for (Variant variant: _variants) { - ((VariantImpl) variant)._removeNameTheme(theme); - } + if (_variants != null && scope != _scope) { + for (Variant variant: _variants) { + ((VariantImpl) variant)._removeNameTheme(theme); } } } Modified: tinytim/trunk/src/main/java/org/tinytim/core/ScopedImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/ScopedImpl.java 2008-11-14 15:51:56 UTC (rev 196) +++ tinytim/trunk/src/main/java/org/tinytim/core/ScopedImpl.java 2008-11-15 13:02:58 UTC (rev 197) @@ -38,12 +38,12 @@ protected IScope _scope; - ScopedImpl(ITopicMap tm) { + protected ScopedImpl(ITopicMap tm) { super(tm); _scope = Scope.UCS; } - ScopedImpl(ITopicMap topicMap, Topic type, IScope scope) { + protected ScopedImpl(ITopicMap topicMap, Topic type, IScope scope) { super(topicMap, type); _scope = scope; } Modified: tinytim/trunk/src/main/java/org/tinytim/core/TypedImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/TypedImpl.java 2008-11-14 15:51:56 UTC (rev 196) +++ tinytim/trunk/src/main/java/org/tinytim/core/TypedImpl.java 2008-11-15 13:02:58 UTC (rev 197) @@ -38,11 +38,11 @@ private Topic _type; private Topic _reifier; - TypedImpl(ITopicMap tm) { + protected TypedImpl(ITopicMap tm) { super(tm); } - TypedImpl(ITopicMap topicMap, Topic type) { + protected TypedImpl(ITopicMap topicMap, Topic type) { super(topicMap); _type = type; } Modified: tinytim/trunk/src/main/java/org/tinytim/core/value/BooleanLiteral.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/value/BooleanLiteral.java 2008-11-14 15:51:56 UTC (rev 196) +++ tinytim/trunk/src/main/java/org/tinytim/core/value/BooleanLiteral.java 2008-11-15 13:02:58 UTC (rev 197) @@ -26,7 +26,7 @@ * * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ final class BooleanLiteral implements ILiteral { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2010-06-03 18:39:30
|
Revision: 396 http://tinytim.svn.sourceforge.net/tinytim/?rev=396&view=rev Author: lheuer Date: 2010-06-03 18:39:23 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Avoid out of memory errors due to the usage of interned strings Modified Paths: -------------- tinytim/trunk/src/main/java/org/tinytim/core/IdentityManager.java tinytim/trunk/src/main/java/org/tinytim/core/value/LocatorImpl.java Modified: tinytim/trunk/src/main/java/org/tinytim/core/IdentityManager.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/IdentityManager.java 2010-05-01 10:43:16 UTC (rev 395) +++ tinytim/trunk/src/main/java/org/tinytim/core/IdentityManager.java 2010-06-03 18:39:23 UTC (rev 396) @@ -50,7 +50,7 @@ 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); @@ -107,7 +107,7 @@ private void _register(IConstruct construct) { ConstructImpl c = (ConstructImpl) construct; if (c._id == null) { - c._id = String.valueOf(IdGenerator.nextId()).intern(); + c._id = String.valueOf(IdGenerator.nextId()); } if (!_id2Construct.containsKey(c._id)) { _id2Construct.put(c._id, c); Modified: tinytim/trunk/src/main/java/org/tinytim/core/value/LocatorImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/core/value/LocatorImpl.java 2010-05-01 10:43:16 UTC (rev 395) +++ tinytim/trunk/src/main/java/org/tinytim/core/value/LocatorImpl.java 2010-06-03 18:39:23 UTC (rev 396) @@ -63,7 +63,7 @@ catch (UnsupportedEncodingException ex) { throw new TMAPIRuntimeException(ex); } - _uri = URI.create(_reference.replace(" ", "%20")); + _uri = URI.create(reference); } private LocatorImpl(URI uri) { @@ -79,6 +79,7 @@ /* (non-Javadoc) * @see org.tinytim.internal.api.ILiteral#getDatatype() */ + @Override public Locator getDatatype() { return XSD.ANY_URI; } @@ -86,6 +87,7 @@ /* (non-Javadoc) * @see org.tinytim.internal.api.ILiteral#getValue() */ + @Override public String getValue() { return _reference; } @@ -93,6 +95,7 @@ /* (non-Javadoc) * @see org.tinytim.internal.api.ILiteral#decimalValue() */ + @Override public BigDecimal decimalValue() { throw new NumberFormatException(); } @@ -100,6 +103,7 @@ /* (non-Javadoc) * @see org.tinytim.internal.api.ILiteral#floatValue() */ + @Override public float floatValue() { throw new NumberFormatException(); } @@ -107,6 +111,7 @@ /* (non-Javadoc) * @see org.tinytim.internal.api.ILiteral#integerValue() */ + @Override public BigInteger integerValue() { throw new NumberFormatException(); } @@ -114,6 +119,7 @@ /* (non-Javadoc) * @see org.tinytim.internal.api.ILiteral#intValue() */ + @Override public int intValue() { throw new NumberFormatException(); } @@ -121,6 +127,7 @@ /* (non-Javadoc) * @see org.tinytim.internal.api.ILiteral#longValue() */ + @Override public long longValue() { throw new NumberFormatException(); } @@ -128,6 +135,7 @@ /* (non-Javadoc) * @see org.tmapi.core.Locator#getReference() */ + @Override public String getReference() { return _reference; } @@ -135,13 +143,18 @@ /* (non-Javadoc) * @see org.tmapi.core.Locator#resolve(java.lang.String) */ + @Override public Locator resolve(String reference) { + if (_EMPTY.equals(reference)) { + return this; + } return create(_uri.resolve(reference)); } /* (non-Javadoc) * @see org.tmapi.core.Locator#toExternalForm() */ + @Override public String toExternalForm() { return _uri.toASCIIString(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |