You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2013/09/06 19:11:31 UTC
[1/4] ISIS-518,
ISIS-519: deprecating applib's Filter and deleting archived code.
Updated Branches:
refs/heads/master 91df99789 -> 52912061f
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/WholeNumber.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/WholeNumber.java b/core/applib/src/main/src-archived/old-valueholders/WholeNumber.java
deleted file mode 100644
index b03c388..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/WholeNumber.java
+++ /dev/null
@@ -1,414 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.BusinessObject;
-import org.apache.isis.application.Title;
-import org.apache.isis.application.value.ValueParseException;
-
-import java.text.NumberFormat;
-import java.text.ParseException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * Value object to represent an integral number.
- * <p>
- * This object <i>does</i> support value listeners.
- * </p>
- */
-public class WholeNumber extends Magnitude {
- private static final NumberFormat FORMAT = NumberFormat.getNumberInstance();
- static {
- FORMAT.setParseIntegerOnly(true);
- }
- private int whole;
- private boolean isNull;
-
- /**
- * Creates a WholeNumber with zero value;
- */
- public WholeNumber() {
- this((BusinessObject) null);
- }
-
- /**
- * Creates a WholeNumber with the specified value;
- */
- public WholeNumber(final int whole) {
- this(null, whole);
- }
-
- /**
- * Creates a WholeNumber with parsed value from the specified text;
- *
- * @deprecated
- */
- public WholeNumber(final String text) {
- super(null);
- try {
- parseUserEntry(text);
- // isNull = false;
- } catch (ValueParseException ignore) {}
- }
-
- /**
- * Creates a WholeNumber with the same value as the specified object;
- */
- public WholeNumber(final WholeNumber wholeNumber) {
- this(null, wholeNumber);
- }
-
- /**
- * Creates a WholeNumber with zero value;
- */
- public WholeNumber(final BusinessObject parent) {
- super(parent);
- clear();
- }
-
- /**
- * Creates a WholeNumber with the specified value;
- */
- public WholeNumber(final BusinessObject parent, final int whole) {
- super(parent);
- setValue(whole);
- }
-
- /**
- * Creates a WholeNumber with the same value as the specified object;
- */
- public WholeNumber(final BusinessObject parent, final WholeNumber wholeNumber) {
- super(parent);
- setValue(wholeNumber);
- }
-
- public WholeNumber(final BusinessObject object, final long l) {
- this(object, (int) l);
- }
-
- /**
- * Adds the specified amount to this value.
- */
- public void add(final int whole) {
- if (this.isEmpty()) {
- return;
- }
- setValue(this.intValue() + whole);
- }
-
- /**
- * Adds the specified value to this value.
- */
- public void add(final WholeNumber whole) {
- if (whole == null || whole.isEmpty()) {
- return;
- }
- add(whole.whole);
- }
-
- public void clear() {
- setValuesInternal(0, true, true);
- }
-
- /**
- * returns the difference between this obect and the value: 0 means they are equal.
- */
- public int compareTo(final int value) {
- return intValue() - value;
- }
-
- public void copyObject(final BusinessValueHolder object) {
- if (!(object instanceof WholeNumber)) {
- throw new IllegalArgumentException("Can only copy the value of a WholeNumber object");
- }
- // isNull = ((WholeNumber) object).isNull;
- // whole = ((WholeNumber) object).whole;
- WholeNumber wholeNumber = (WholeNumber) object;
- setValue(wholeNumber);
- }
-
- /**
- * Divides this value by the specified amount.
- */
- public void divide(final int whole) {
- setValue(intValue() / whole);
- }
-
- /**
- * Divides this value by the specified amount.
- */
- public void divide(final double whole) {
- setValue((int) (intValue() / whole));
- }
-
- /**
- * Divides this value by the specified amount.
- */
- public void divide(final WholeNumber number) {
- if (number == null || number.isEmpty()) {
- return;
- }
- divide(number.whole);
- }
-
- /**
- * Returns this value as an double.
- */
- public double doubleValue() {
- ensureAtLeastPartResolved();
- return (double) whole;
- }
-
- public boolean equals(final Object object) {
- ensureAtLeastPartResolved();
- if (object instanceof WholeNumber) {
- return ((WholeNumber) object).whole == whole;
- }
- return super.equals(object);
- }
-
- /**
- * Returns this value as an float.
- */
- public float floatValue() {
- ensureAtLeastPartResolved();
- return (float) whole;
- }
-
- /**
- * Returns this value as an int.
- *
- * @deprecated
- * @see #intValue
- */
- public int getInt() {
- ensureAtLeastPartResolved();
- return whole;
- }
-
- public String getObjectHelpText() {
- return "A Whole Number object.";
- }
-
- /**
- * Returns this value as an int.
- */
- public int intValue() {
- ensureAtLeastPartResolved();
- return whole;
- }
-
- public boolean isEmpty() {
- ensureAtLeastPartResolved();
- return isNull;
- }
-
- /**
- * returns true if the number of this object has the same value as the specified number
- */
- public boolean isEqualTo(final Magnitude number) {
- ensureAtLeastPartResolved();
- if (number instanceof WholeNumber) {
- if (isNull) {
- return number.isEmpty();
- }
- return ((WholeNumber) number).whole == whole;
- } else {
- throw new IllegalArgumentException("Parameter must be of type WholeNumber");
- }
- }
-
- /**
- * Returns true if this value is less than the specified value.
- */
- public boolean isLessThan(final Magnitude value) {
- ensureAtLeastPartResolved();
- if (value instanceof WholeNumber) {
- return !isNull && !value.isEmpty() && whole < ((WholeNumber) value).whole;
- } else {
- throw new IllegalArgumentException("Parameter must be of type WholeNumber");
- }
- }
-
- /**
- * Returns true if this value is less than 0.
- */
- public boolean isNegative() {
- ensureAtLeastPartResolved();
- return whole < 0;
- }
-
- /**
- * Returns true if this value is 0.
- */
- public boolean isZero() {
- ensureAtLeastPartResolved();
- return whole == 0;
- }
-
- /**
- * Returns this value as an long.
- */
- public long longValue() {
- ensureAtLeastPartResolved();
- return (long) whole;
- }
-
- /**
- * Multiply this value by the specified amount.
- */
- public void multiply(final int whole) {
- setValue((int) (this.whole * whole));
- }
-
- /**
- * Multiply this value by the specified amount.
- */
- public void multiply(final WholeNumber number) {
- multiply(number.whole);
- }
-
- public void parseUserEntry(final String text) throws ValueParseException {
- if (text.trim().equals("")) {
- clear();
- } else {
- try {
- setValue(FORMAT.parse(text).intValue());
- } catch (ParseException e) {
- throw new ValueParseException("Invalid number", e);
- }
- }
- }
-
- /**
- * Reset this whole number so it contains 0.
- */
- public void reset() {
- setValue(0);
- }
-
- /**
- * Sets this value to be the specified value.
- */
- public void set(final int whole) {
- setValue(whole);
- }
-
- /**
- * Sets this value to be the same and specified value.
- *
- * @deprecated replaced by setValue
- */
- public void set(final WholeNumber value) {
- setValue(value.whole);
- }
-
- /**
- * Sets this value to be the specified value.
- *
- * @deprecated replaced by setValue
- */
- public void setInt(final int whole) {
- setValue(whole);
- }
-
- public void setValue(final int whole) {
- setValuesInternal(whole, false, true);
- }
-
- public void setValue(final WholeNumber value) {
- if (value.isEmpty()) {
- clear();
- } else {
- setValuesInternal(value.whole, value.isNull, true);
- }
- }
-
- private void setValuesInternal(final int value, final boolean isNull, final boolean notify) {
- if (notify) {
- ensureAtLeastPartResolved();
- }
- this.whole = value;
- this.isNull = isNull;
- if (notify) {
- parentChanged();
- }
- }
-
- /**
- * Returns this value as an short.
- */
- public short shortValue() {
- ensureAtLeastPartResolved();
- return (short) whole;
- }
-
- /**
- * Substracts the specified amount from this value.
- */
- public void subtract(final int whole) {
- add(-whole);
- }
-
- /**
- * Subtracts the specified amount from this value.
- */
- public void subtract(final WholeNumber number) {
- subtract(number.whole);
- }
-
- /**
- * if non-null, makes the value positive.
- */
- public void abs() {
- if (this.isEmpty()) {
- return;
- }
- setValue(Math.abs(this.intValue()));
- }
-
- public Title title() {
- ensureAtLeastPartResolved();
- return new Title(isNull ? "" : FORMAT.format(whole));
- }
-
- public void restoreFromEncodedString(final String data) {
- if (data == null || data.equals("NULL")) {
- setValuesInternal(0, true, false);
- } else {
- setValuesInternal(Integer.valueOf(data).intValue(), false, false);
- }
- }
-
- public String asEncodedString() {
- return isEmpty() ? "NULL" : String.valueOf(intValue());
- }
-
- protected LoggerFactory.getLogger() {
- return logger;
- }
-
- private final static Logger logger = LoggerFactory.getLogger(WholeNumber.class);
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/WholeNumberTests.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/WholeNumberTests.java b/core/applib/src/main/src-archived/old-valueholders/WholeNumberTests.java
deleted file mode 100644
index 24c7850..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/WholeNumberTests.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.LoggerFactory;
-
-
-public class WholeNumberTests extends ValueTestCase {
-
- public static void main(final String[] args) {
- LogManager.getLoggerRepository().setThreshold(Level.OFF);
- TestRunner.run(new TestSuite(WholeNumberTests.class));
- }
-
- public void testEquals() throws NoSuchMethodException {
- WholeNumber one = new WholeNumber(189);
- WholeNumber two = new WholeNumber(189);
- WholeNumber three = new WholeNumber(1890);
-
- assertEquals(one, two);
- assertEquals(two, one);
- assertTrue(!one.equals(three));
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/XmlString.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/XmlString.java b/core/applib/src/main/src-archived/old-valueholders/XmlString.java
deleted file mode 100644
index 9b013e6..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/XmlString.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.BusinessObject;
-
-
-public class XmlString extends MultilineTextString {
-
- public XmlString() {
- this(null);
- }
-
- public XmlString(final BusinessObject parent) {
- super(parent);
- }
-
- /**
- * Determines if the user can change this type of object: no in the case of XmlValues.
- */
- public boolean userChangeable() {
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java
index 5be28f8..52dbf7b 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java
@@ -22,10 +22,13 @@ package org.apache.isis.core.metamodel.services.container;
import java.util.ArrayList;
import java.util.List;
+import com.google.common.base.Predicate;
+
import org.apache.isis.applib.DomainObjectContainer;
import org.apache.isis.applib.PersistFailedException;
import org.apache.isis.applib.RepositoryException;
import org.apache.isis.applib.filter.Filter;
+import org.apache.isis.applib.filter.Filters;
import org.apache.isis.applib.query.Query;
import org.apache.isis.applib.query.QueryFindAllInstances;
import org.apache.isis.applib.security.RoleMemento;
@@ -319,7 +322,7 @@ public class DomainObjectContainerDefault implements DomainObjectContainer, Que
}
// //////////////////////////////////////////////////////////////////
- // allInstances, allMatches
+ // allInstances
// //////////////////////////////////////////////////////////////////
@Override
@@ -327,18 +330,28 @@ public class DomainObjectContainerDefault implements DomainObjectContainer, Que
return allMatches(new QueryFindAllInstances<T>(type, range));
}
+ // //////////////////////////////////////////////////////////////////
+ // allMatches
+ // //////////////////////////////////////////////////////////////////
+
@Override
- public <T> List<T> allMatches(final Class<T> cls, final Filter<? super T> filter, long... range) {
+ public <T> List<T> allMatches(final Class<T> cls, final Predicate<? super T> predicate, long... range) {
final List<T> allInstances = allInstances(cls, range);
final List<T> filtered = new ArrayList<T>();
for (final T instance : allInstances) {
- if (filter.accept(instance)) {
+ if (predicate.apply(instance)) {
filtered.add(instance);
}
}
return filtered;
}
+ @Deprecated
+ @Override
+ public <T> List<T> allMatches(final Class<T> cls, final Filter<? super T> filter, long... range) {
+ return allMatches(cls, Filters.asPredicate(filter), range);
+ }
+
@Override
public <T> List<T> allMatches(final Class<T> type, final T pattern, long... range) {
Assert.assertTrue("pattern not compatible with type", type.isAssignableFrom(pattern.getClass()));
@@ -362,16 +375,22 @@ public class DomainObjectContainerDefault implements DomainObjectContainer, Que
// //////////////////////////////////////////////////////////////////
@Override
- public <T> T firstMatch(final Class<T> cls, final Filter<T> filter) {
+ public <T> T firstMatch(final Class<T> cls, final Predicate<T> predicate) {
final List<T> allInstances = allInstances(cls); // Have to fetch all, as matching is done in next loop
for (final T instance : allInstances) {
- if (filter.accept(instance)) {
+ if (predicate.apply(instance)) {
return instance;
}
}
return null;
}
+ @Deprecated
+ @Override
+ public <T> T firstMatch(final Class<T> cls, final Filter<T> filter) {
+ return firstMatch(cls, Filters.asPredicate(filter));
+ }
+
@Override
public <T> T firstMatch(final Class<T> type, final T pattern) {
final List<T> instances = allMatches(type, pattern, 0, 1); // No need to fetch more than 1
@@ -397,6 +416,16 @@ public class DomainObjectContainerDefault implements DomainObjectContainer, Que
// //////////////////////////////////////////////////////////////////
@Override
+ public <T> T uniqueMatch(final Class<T> type, final Predicate<T> predicate) {
+ final List<T> instances = allMatches(type, predicate, 0, 2); // No need to fetch more than 2.
+ if (instances.size() > 1) {
+ throw new RepositoryException("Found more than one instance of " + type + " matching filter " + predicate);
+ }
+ return firstInstanceElseNull(instances);
+ }
+
+ @Deprecated
+ @Override
public <T> T uniqueMatch(final Class<T> type, final Filter<T> filter) {
final List<T> instances = allMatches(type, filter, 0, 2); // No need to fetch more than 2.
if (instances.size() > 1) {
@@ -404,7 +433,7 @@ public class DomainObjectContainerDefault implements DomainObjectContainer, Que
}
return firstInstanceElseNull(instances);
}
-
+
@Override
public <T> T uniqueMatch(final Class<T> type, final T pattern) {
final List<T> instances = allMatches(type, pattern, 0, 2); // No need to fetch more than 2.
[2/4] ISIS-518,
ISIS-519: deprecating applib's Filter and deleting archived code.
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/RtfValue.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/RtfValue.java b/core/applib/src/main/src-archived/old-valueholders/RtfValue.java
deleted file mode 100644
index 4d5ad03..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/RtfValue.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.ApplicationException;
-import org.apache.isis.application.BusinessObject;
-import org.apache.isis.application.Title;
-import org.apache.isis.application.value.ValueParseException;
-
-
-/**
- * <h3>Implementation Notes</h3>
- *
- * This is a little risky, but just using <code>data.getBytes("UTF-8")</code>. This perhaps
- * should be replaced with UUDecoding, or (more fundamentally) the Value interface should change.
- * <p>
- * But the above *might* do (haven't tested this out yet), because RTF uses either 7-bit or (for MS Word)
- * 8-bit character sets and no more. To quote the RTF 1.5 spec:
- *
- * <pre>
- *
- * An RTF file consists of unformatted text, control words, control symbols, and groups.
- * For ease of transport, a standard RTF file can consist of only 7-bit ASCII characters.
- * (Converters that communicate with Microsoft Word for Windows or Microsoft Word for the
- * Macintosh should expect 8-bit characters.)
- *
- * </pre>
- *
- * @see #parseUserEntry(String)
- * @see <a href="http://www.biblioscape.com/rtf15_spec.htm#Heading2">RTF Syntax</a>
- */
-public class RtfValue extends BusinessValueHolder {
-
- public RtfValue() {
- super(null);
- }
-
- public RtfValue(final BusinessObject parent) {
- super(parent);
- }
-
- private String utf8Encoded;
-
- /**
- * Clears the value so that it is empty, i.e. <code>isEmpty</code> returns <code>true</code>.
- */
- public void clear() {
- setValuesInternal(null, true);
- }
-
- /**
- * Copies the content of the specified object into this object.
- */
- public void copyObject(final BusinessValueHolder other) {
- if (!(other instanceof RtfValue)) {
- throw new ApplicationException("only support copying from other RTF values");
- }
- copyObject((RtfValue) other);
- }
-
- public void copyObject(final RtfValue other) {
- setValue(other.utf8Encoded);
- }
-
- /**
- * if <code>isEmpty()</code> then returns null.
- */
- public byte[] getBytes() {
- ensureAtLeastPartResolved();
- if (utf8Encoded == null) {
- return null;
- }
- try {
- return utf8Encoded.getBytes("UTF-8");
- } catch (java.io.UnsupportedEncodingException ex) {
- throw new ApplicationException(ex);
- }
- }
-
- /**
- * Returns true if the value contains no data, e.g. no entry has been made. A call to clear should remove
- * the value, so this call will then return true.
- */
- public boolean isEmpty() {
- ensureAtLeastPartResolved();
- return utf8Encoded == null;
- }
-
- /**
- * Checks to see if two objects contain the same information. Compare with <code>equals</code>, which
- * determines if the one object is replaceable with another.
- *
- * @param other
- * the object to compare
- * @return true if the objects have the same content, and false if the objects are of different types or
- * their contents are deemed to be different.
- */
- public boolean isSameAs(final BusinessValueHolder other) {
- ensureAtLeastPartResolved();
- return other instanceof RtfValue && isSameAs((RtfValue) other);
- }
-
- public boolean isSameAs(final RtfValue other) {
- ensureAtLeastPartResolved();
- if (utf8Encoded == null && other.utf8Encoded == null)
- return true;
- if (utf8Encoded == null || other.utf8Encoded == null)
- return false;
- return utf8Encoded.equals(other.utf8Encoded);
- }
-
- public void parseUserEntry(final String text) throws ValueParseException {
- setValue(text);
- }
-
- /**
- * Resets a value to its default value. Since for a RTF there is no default, does the same as the
- * <code>clear</code> method.
- */
- public void reset() {
- setValue("");
- }
-
- /**
- * Takes a storage string and uses it reinstate this value object to its previous state.
- *
- */
- public void restoreFromEncodedString(final String utf8Encoded) {
- if (utf8Encoded == null || utf8Encoded.equals("NULL")) {
- setValuesInternal(null, false);
- } else {
- setValuesInternal(utf8Encoded, false);
- }
- }
-
- /**
- * Returns a basic string representation of this value for storage purposes.
- *
- * @see #restoreFromEncodedString(String)
- */
- public String asEncodedString() {
- return isEmpty() ? "NULL" : utf8Encoded;
- }
-
- public void setValue(final String value) {
- setValuesInternal(value, true);
- }
-
- private void setValuesInternal(final String value, final boolean notify) {
- if (notify) {
- ensureAtLeastPartResolved();
- }
- this.utf8Encoded = value;
- if (notify) {
- parentChanged();
- }
- }
-
- public Title title() {
- return new Title(titleString());
- }
-
- public String titleString() {
- ensureAtLeastPartResolved();
- return (utf8Encoded != null ? "not " : "") + "empty";
- }
-
- /**
- * Determines if the user can change this type of object: no in the case of RtfValues.
- */
- public boolean userChangeable() {
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/SerialNumber.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/SerialNumber.java b/core/applib/src/main/src-archived/old-valueholders/SerialNumber.java
deleted file mode 100644
index ffcbb3a..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/SerialNumber.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.BusinessObject;
-import org.apache.isis.application.Title;
-import org.apache.isis.application.value.ValueParseException;
-
-import java.text.NumberFormat;
-import java.text.ParseException;
-
-
-public class SerialNumber extends Magnitude {
- private static final NumberFormat FORMAT = NumberFormat.getNumberInstance();
- private boolean isNull;
- private long number;
-
- public SerialNumber() {
- this(null);
- }
-
- public SerialNumber(final BusinessObject parent) {
- super(parent);
- }
-
- public void clear() {
- setValuesInternal(0, true, true);
- }
-
- public void copyObject(final BusinessValueHolder object) {
- if (!(object instanceof SerialNumber)) {
- throw new IllegalArgumentException("Can only copy the value of a WholeNumber object");
- }
- SerialNumber number = (SerialNumber) object;
- setValue(number);
- }
-
- public boolean isEmpty() {
- ensureAtLeastPartResolved();
- return isNull;
- }
-
- /**
- * returns true if the number of this object has the same value as the specified number
- */
- public boolean isEqualTo(final Magnitude value) {
- ensureAtLeastPartResolved();
- if (value instanceof SerialNumber) {
- if (isNull) {
- return value.isEmpty();
- }
- return ((SerialNumber) value).number == number;
- } else {
- throw new IllegalArgumentException("Parameter must be of type WholeNumber");
- }
- }
-
- /**
- * Returns true if this value is less than the specified value.
- */
- public boolean isLessThan(final Magnitude value) {
- ensureAtLeastPartResolved();
- if (value instanceof SerialNumber) {
- return !isNull && !value.isEmpty() && number < ((SerialNumber) value).number;
- } else {
- throw new IllegalArgumentException("Parameter must be of type WholeNumber");
- }
- }
-
- public long longValue() {
- ensureAtLeastPartResolved();
- return (long) number;
- }
-
- public void parseUserEntry(final String text) throws ValueParseException {
- if (text.trim().equals("")) {
- clear();
- } else {
- try {
- setValue(FORMAT.parse(text).longValue());
- } catch (ParseException e) {
- throw new ValueParseException("Invalid number", e);
- }
- }
- }
-
- /**
- * Reset this whole number so it contains 0.
- *
- *
- */
- public void reset() {
- setValue(0);
- }
-
- public void restoreFromEncodedString(final String data) {
- if (data == null || data.equals(("NULL"))) {
- setValuesInternal(0, true, false);
- } else {
- setValuesInternal(Integer.valueOf(data).intValue(), false, false);
- }
- }
-
- public String asEncodedString() {
- return isEmpty() ? "NULL" : String.valueOf(longValue());
- }
-
- public void setValue(final long number) {
- setValuesInternal(number, false, true);
- }
-
- public void setValue(final SerialNumber number) {
- setValuesInternal(number.number, number.isNull, true);
- }
-
- private void setValuesInternal(final long number, final boolean isNull, final boolean notify) {
- if (notify) {
- ensureAtLeastPartResolved();
- }
- this.number = number;
- this.isNull = isNull;
- if (notify) {
- parentChanged();
- }
- }
-
- public Title title() {
- ensureAtLeastPartResolved();
- return new Title(isNull ? "" : String.valueOf(number));
- }
-
- public void next() {
- ensureAtLeastPartResolved();
- number++;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/SimpleState.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/SimpleState.java b/core/applib/src/main/src-archived/old-valueholders/SimpleState.java
deleted file mode 100644
index 4f6eb96..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/SimpleState.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.ApplicationException;
-import org.apache.isis.application.BusinessObject;
-import org.apache.isis.application.Title;
-import org.apache.isis.application.control.State;
-import org.apache.isis.application.value.ValueParseException;
-
-
-public class SimpleState extends BusinessValueHolder implements State {
- private static final long serialVersionUID = 1L;
- private String name;
- private int id;
- private State[] states;
-
- public SimpleState(final int id, final String name) {
- this(null, id, name);
- }
-
- public SimpleState(final State[] states) {
- this(null, states);
- }
-
- public SimpleState(final BusinessObject parent, final int id, final String name) {
- super(parent);
- if (id < 0) {
- throw new IllegalArgumentException("Id must be 0 or greater");
- }
-
- this.id = id;
- this.name = name;
- }
-
- public SimpleState(final BusinessObject parent, final State[] states) {
- super(parent);
- this.states = states;
- }
-
- public String getName() {
- ensureAtLeastPartResolved();
- return name;
- }
-
- public Object getValue() {
- ensureAtLeastPartResolved();
- return this;
- }
-
- public boolean userChangeable() {
- return false;
- }
-
- public void clear() {
- id = -1;
- name = null;
- parentChanged();
- }
-
- public void parseUserEntry(final String text) throws ValueParseException {
- setState(text, true);
- }
-
- public void reset() {
- id = -1;
- name = null;
- parentChanged();
- }
-
- public void restoreFromEncodedString(final String data) {
- id = Integer.valueOf(data).intValue();
- name = "unmatched state";
- for (int i = 0; i < states.length; i++) {
- if (id == ((SimpleState) states[i]).id) {
- name = ((SimpleState) states[i]).name;
- break;
- }
- }
- }
-
- public void setValue(final String stateName) {
- if ((stateName == null)) {
- this.clear();
- } else {
- setState(stateName, true);
- }
- }
-
- private void setState(final String stateName, final boolean notify) {
-
- if (this.states == null) {
- return;
- }
- for (int i = 0; i < states.length; i++) {
- SimpleState state = (SimpleState) states[i];
- if (state.name.equals(stateName)) {
- setValuesInternal(state.id, state.name, notify);
- return;
- }
- }
- }
-
- private void setValuesInternal(final int id, final String name, final boolean notify) {
-
- if (notify) {
- ensureAtLeastPartResolved();
- }
- this.id = id; // -1 means null.
- this.name = name;
- if (notify) {
- parentChanged();
- }
- }
-
- public String asEncodedString() {
- ensureAtLeastPartResolved();
- return String.valueOf(id);
- }
-
- public void copyObject(final BusinessValueHolder object) {
- throw new ApplicationException();
- }
-
- public boolean isEmpty() {
- ensureAtLeastPartResolved();
- return id == -1;
- }
-
- public boolean equals(final Object object) {
- ensureAtLeastPartResolved();
- if (object instanceof SimpleState) {
- int cid = ((SimpleState) object).id;
- if (cid == id) {
- return true;
- }
- }
- return false;
- }
-
- public boolean isSameAs(final BusinessValueHolder object) {
- ensureAtLeastPartResolved();
- if (object instanceof SimpleState) {
- int cid = ((SimpleState) object).id;
- if (cid == id) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * copies the state across from the specified state
- */
- public void changeTo(final State state) {
- SimpleState ss = (SimpleState) state;
- setValuesInternal(ss.id, ss.name, true);
- }
-
- public String titleString() {
- ensureAtLeastPartResolved();
- return name;
- }
-
- public Title title() {
- return new Title(titleString());
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/TestClock.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/TestClock.java b/core/applib/src/main/src-archived/old-valueholders/TestClock.java
deleted file mode 100644
index a2e8a39..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/TestClock.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.system;
-
-import org.apache.isis.application.Clock;
-import org.apache.isis.application.valueholder.Date;
-import org.apache.isis.application.valueholder.DateTime;
-import org.apache.isis.application.valueholder.Time;
-import org.apache.isis.application.valueholder.TimeStamp;
-
-import java.util.Calendar;
-import java.util.Locale;
-import java.util.TimeZone;
-
-
-public class TestClock implements Clock {
- private static final TimeZone timeZone;
- static {
- timeZone = TimeZone.getTimeZone("GMT");
- Locale.setDefault(Locale.UK);
- }
-
- public TestClock() {
- Date.setClock(this);
- Time.setClock(this);
- DateTime.setClock(this);
- TimeStamp.setClock(this);
- }
-
- /**
- * Always return the time as 2003/8/17 21:30:25
- */
- public long getTime() {
- Calendar c = Calendar.getInstance();
- c.setTimeZone(timeZone);
-
- c.set(Calendar.MILLISECOND, 0);
-
- c.set(Calendar.YEAR, 2003);
- c.set(Calendar.MONTH, 7);
- c.set(Calendar.DAY_OF_MONTH, 17);
-
- c.set(Calendar.HOUR_OF_DAY, 21);
- c.set(Calendar.MINUTE, 30);
- c.set(Calendar.SECOND, 25);
-
- return c.getTime().getTime();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/TextString.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/TextString.java b/core/applib/src/main/src-archived/old-valueholders/TextString.java
deleted file mode 100644
index 0f8a8f5..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/TextString.java
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.BusinessObject;
-import org.apache.isis.application.Title;
-import org.apache.isis.application.value.ValueParseException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * Value object representing an unformatted text string of unbounded length.
- * <p>
- * This object <i>does </i> support value listeners.
- * </p>
- */
-public class TextString extends BusinessValueHolder {
- private final static Logger logger = LoggerFactory.getLogger(TextString.class);
- private static final long serialVersionUID = 1L;
- private int maximumLength = 0;
- private int minimumLength = 0;
- private String text;
-
- /**
- * Creates an empty TextString.
- */
- public TextString() {
- this((BusinessObject) null);
- }
-
- /**
- * Creates a TextString containing the specified text.
- */
- public TextString(final String text) {
- this(null, text);
- }
-
- /**
- * Creates a TextString containing a copy of the text in the specified TextString.
- */
- public TextString(final TextString textString) {
- this(null, textString);
- }
-
- /**
- * Creates an empty TextString.
- */
- public TextString(final BusinessObject parent) {
- super(parent);
- this.clear();
- }
-
- /**
- * Creates a TextString containing the specified text.
- */
- public TextString(final BusinessObject parent, final String text) {
- super(parent);
- setValue(text);
- }
-
- /**
- * Creates a TextString containing a copy of the text in the specified TextString.
- */
- public TextString(final BusinessObject parent, final TextString textString) {
- super(parent);
- setValue(textString);
- }
-
- public String asEncodedString() {
- return isEmpty() ? "NULL" : text;
- }
-
- /**
- *
- */
- private void checkForInvalidCharacters() {
- if (text == null) {
- return;
- }
-
- for (int i = 0; i < text.length(); i++) {
- if (isCharDisallowed(text.charAt(i))) {
- throw new RuntimeException(getClass() + " cannot contain the character code 0x"
- + Integer.toHexString(text.charAt(i)));
- }
- }
- }
-
- /**
- * clears the value (sets to null) and notifies any listeners.
- */
- public void clear() {
- setValuesInternal(null, true);
- }
-
- /**
- * Returns true if the specified text is found withing this object.
- */
- public boolean contains(final String text) {
- return contains(text, Case.SENSITIVE);
- }
-
- /**
- * Returns true if the specified text is found withing this object. If caseSensitive is false then
- * differences in case are ignored.
- */
- public boolean contains(final String text, final Case caseSensitive) {
- ensureAtLeastPartResolved();
- if (this.text == null) {
- return false;
- }
-
- if (caseSensitive == Case.SENSITIVE) {
- return this.text.indexOf(text) >= 0;
- } else {
- return this.text.toLowerCase().indexOf(text.toLowerCase()) >= 0;
- }
- }
-
- public void copyObject(final BusinessValueHolder object) {
- if (!(object instanceof TextString)) {
- throw new IllegalArgumentException("Can only copy the value of a TextString object");
- }
-
- TextString textString = (TextString) object;
- setValue(textString);
- }
-
- /**
- * Returns true if the specified text is found at the end of this object's text.
- */
- public boolean endsWith(final String text) {
- return endsWith(text, Case.SENSITIVE);
- }
-
- /**
- * Returns true if the specified text is found at the end of this object's text. If caseSensitive is false
- * then differences in case are ignored.
- */
- public boolean endsWith(final String text, final Case caseSensitive) {
- ensureAtLeastPartResolved();
- if (this.text == null) {
- return false;
- }
-
- if (caseSensitive == Case.SENSITIVE) {
- return this.text.endsWith(text);
- } else {
- return this.text.toLowerCase().endsWith(text.toLowerCase());
- }
- }
-
- /**
- * @deprecated replaced by isSameAs
- */
- public boolean equals(final Object object) {
- ensureAtLeastPartResolved();
- if (object instanceof TextString) {
- TextString other = (TextString) object;
-
- if (this.text == null) {
- return other.text == null;
- }
-
- return this.text.equals(other.text);
- }
-
- return super.equals(object);
- }
-
- protected LoggerFactory.getLogger() {
- return logger;
- }
-
- public int getMaximumLength() {
- return maximumLength;
- }
-
- public int getMinimumLength() {
- return minimumLength;
- }
-
- public String getObjectHelpText() {
- return "A TextString object.";
- }
-
- /**
- * disallow CR, LF and TAB
- */
- protected boolean isCharDisallowed(final char c) {
- return c == '\n' || c == '\r' || c == '\t';
- }
-
- /**
- * Returns true if this object's text has no characters in it.
- */
- public boolean isEmpty() {
- ensureAtLeastPartResolved();
- return text == null || text.length() == 0;
- }
-
- /**
- * delegates the comparsion to the <code>isSameAs(TextString)</code> method if specified object is a
- * <code>TextString</code> else returns false.
- *
- * @see BusinessValueHolder#isSameAs(BusinessValueHolder)
- */
- public boolean isSameAs(final BusinessValueHolder object) {
- if (object instanceof TextString) {
- return isSameAs((TextString) object);
- } else {
- return false;
- }
- }
-
- /**
- * Returns true if the specified text is the same as (for all characters) the object's text.
- */
- public boolean isSameAs(final String text) {
- return isSameAs(text, Case.SENSITIVE);
- }
-
- /**
- * Returns true if the specified text is the same as (for all characters) the object's text. If
- * caseSensitive is false then differences in case are ignored.
- */
- public boolean isSameAs(final String text, final Case caseSensitive) {
- ensureAtLeastPartResolved();
- if (this.text == null) {
- return false;
- }
-
- if (caseSensitive == Case.SENSITIVE) {
- return this.text.equals(text);
- } else {
- return this.text.equalsIgnoreCase(text);
- }
- }
-
- /**
- * Returns true if the specified text is the same as (for all characters) the object's text.
- */
- public boolean isSameAs(final TextString text) {
- return isSameAs(text, Case.SENSITIVE);
- }
-
- /**
- * Returns true if the specified text is the same as (for all characters) the object's text. If
- * caseSensitive is false then differences in case are ignored.
- */
- public boolean isSameAs(final TextString text, final Case caseSensitive) {
- ensureAtLeastPartResolved();
- if (this.text == null) {
- return this.text == text.text;
- }
-
- if (caseSensitive == Case.SENSITIVE) {
- return this.text.equals(text.text);
- } else {
- return this.text.equalsIgnoreCase(text.text);
- }
- }
-
- // TODO remove this method from interface
- public boolean isValid() {
- return false;
- }
-
- public void parseUserEntry(final String text) throws ValueParseException {
- setValue(text);
- }
-
- /**
- * Reset this string so it set to null (therefore equivalent to clear())
- *
- * @see #clear()
- */
- public void reset() {
- setValue((String) null);
- }
-
- public void restoreFromEncodedString(final String data) {
- if (data == null || data.equals("NULL")) {
- setValuesInternal(null, false);
- } else {
- setValuesInternal(data, false);
- checkForInvalidCharacters();
- }
- }
-
- public void setMaximumLength(final int maximumLength) {
- this.maximumLength = maximumLength;
- }
-
- public void setMinimumLength(final int minimumLength) {
- this.minimumLength = minimumLength;
- }
-
- /**
- * Sets this object text to be same as the specified text.
- */
- public void setValue(final String text) {
- setValuesInternal(text, true);
- checkForInvalidCharacters();
- }
-
- /**
- * Sets this object text to be same as the specified text.
- */
- public void setValue(final TextString text) {
- if (text == null || text.isEmpty()) {
- clear();
- } else {
- setValuesInternal(text.text, true);
- }
- }
-
- private void setValuesInternal(final String value, final boolean notify) {
- if (notify) {
- ensureAtLeastPartResolved();
- }
- this.text = value;
- // computeWhetherIsEmptyAndStringValue();
- if (notify) {
- parentChanged();
- }
- }
-
- /**
- * Returns true if the specified text is found at the beginning of this object's text.
- */
- public boolean startsWith(final String text) {
- return startsWith(text, Case.SENSITIVE);
- }
-
- /**
- * Returns true if the specified text is found at the beginning of this object's text. If caseSensitive is
- * false then differences in case are ignored.
- */
- public boolean startsWith(final String text, final Case caseSensitive) {
- ensureAtLeastPartResolved();
- if (this.text == null) {
- return false;
- }
-
- if (caseSensitive == Case.SENSITIVE) {
- return this.text.startsWith(text);
- } else {
- return this.text.toLowerCase().startsWith(text.toLowerCase());
- }
- }
-
- public String stringValue() {
- return isEmpty() ? "" : text;
- }
-
- public Title title() {
- return new Title(stringValue());
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/TextStringTests.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/TextStringTests.java b/core/applib/src/main/src-archived/old-valueholders/TextStringTests.java
deleted file mode 100644
index 0e6af17..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/TextStringTests.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-public class TextStringTests extends ValueTestCase {
- public static void main(final String[] args) {
- junit.textui.TestRunner.run(TextStringTests.class);
- }
-
- public void testInvalidCharacters() {
- try {
- TextString t = new TextString();
- t.setValue("Hello\nYou");
- fail("Exception expected");
- } catch (RuntimeException expected) {}
- try {
- new TextString("Hello\nYou");
- fail("Exception expected");
- } catch (RuntimeException expected) {}
- }
-
- public void testValidCharacters() {
- String text = "Hello You";
- TextString t = new TextString(text);
- assertEquals(text, t.title().toString());
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/Time.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/Time.java b/core/applib/src/main/src-archived/old-valueholders/Time.java
deleted file mode 100644
index 2d72bda..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/Time.java
+++ /dev/null
@@ -1,469 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.ApplicationException;
-import org.apache.isis.application.BusinessObject;
-import org.apache.isis.application.Clock;
-import org.apache.isis.application.Title;
-import org.apache.isis.application.value.ValueParseException;
-
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Locale;
-import java.util.TimeZone;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * Value object representing a time value.
- * <p>
- * NOTE: this class currently does not support about listeners
- * </p>
- */
-
-/*
- * other methods to implement
- *
- * comparision methods
- *
- * sameHourAs() hour ==hour sameMinuteAs() minutes = minutes sameTimeAs(hour, min) hour == hour & minutes ==
- * minutes
- *
- * withinNextTimePeriod(int hours, int minutes); withinTimePeriod(Date d, int hours, int minutes);
- * withinPreviousTimePeriod(int hours, int minutes); d.hour >= this.hour >= d.hour + hours & d.minutes >=
- * this.minutes >= d.minutes + minutes
- */
-public class Time extends Magnitude {
- private static Clock clock;
- private static final DateFormat ISO_LONG = new SimpleDateFormat("HH:mm");
- private static final DateFormat ISO_SHORT = new SimpleDateFormat("HHmm");
- private static final Logger LOG = LoggerFactory.getLogger(Time.class);
- private static final DateFormat LONG_FORMAT = DateFormat.getTimeInstance(DateFormat.LONG);
- private static final DateFormat MEDIUM_FORMAT = DateFormat.getTimeInstance(DateFormat.MEDIUM);
- public static final int MINUTE = 60;
- public static final int HOUR = 60 * MINUTE;
- public static final int DAY = 24 * HOUR;
- private static final long serialVersionUID = 1L;
- private static final DateFormat SHORT_FORMAT = DateFormat.getTimeInstance(DateFormat.SHORT);
- private static final TimeZone timeZone;
- private final static long zero;
-
- static {
- timeZone = TimeZone.getTimeZone("GMT");
- ISO_LONG.setTimeZone(timeZone);
- ISO_SHORT.setTimeZone(timeZone);
- LONG_FORMAT.setTimeZone(timeZone);
- MEDIUM_FORMAT.setTimeZone(timeZone);
- SHORT_FORMAT.setTimeZone(timeZone);
-
- ISO_LONG.setLenient(false);
- ISO_SHORT.setLenient(false);
- LONG_FORMAT.setLenient(false);
- MEDIUM_FORMAT.setLenient(false);
- SHORT_FORMAT.setLenient(false);
-
- Calendar cal = Calendar.getInstance();
- cal.setTimeZone(timeZone);
- // set to 1-Jan-1970 00:00:00 (the epoch)
- cal.set(Calendar.MILLISECOND, 0);
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.MINUTE, 0);
- cal.set(Calendar.HOUR_OF_DAY, 0);
- cal.clear(Calendar.AM_PM);
- cal.clear(Calendar.HOUR);
- cal.set(Calendar.DAY_OF_MONTH, 1);
- cal.set(Calendar.MONTH, 0);
- cal.set(Calendar.YEAR, 1970);
- zero = cal.getTime().getTime();
-
- LOG.debug("locale " + Locale.getDefault());
- LOG.debug("short fomat " + SHORT_FORMAT.format(new Date()));
- LOG.debug("medium fomat " + MEDIUM_FORMAT.format(new Date()));
- LOG.debug("long fomat " + LONG_FORMAT.format(new Date()));
- }
-
- static long getZero() {
- return zero / 1000;
- }
-
- public static void setClock(final Clock clock) {
- Time.clock = clock;
- }
-
- private java.util.Date date;
-
- /*
- * Create a Time object for storing a time with the time set to the current time.
- */
- public Time() {
- this((BusinessObject) null);
- }
-
- /*
- * Create a Time object for storing a time with the time set to the specified hours and minutes.
- */
- public Time(final int hour, final int minute) {
- this(null, hour, minute);
- }
-
- /*
- * Create a Time object for storing a time with the time set to the specified time.
- */
- public Time(final Time time) {
- this(null, time);
- }
-
- /*
- * Create a Time object for storing a time with the time set to the current time.
- */
- public Time(final BusinessObject parent) {
- super(parent);
- if (clock == null) {
- throw new ApplicationException("Clock not set up");
- }
- setValue(new java.util.Date(clock.getTime()));
- }
-
- /*
- * Create a Time object for storing a time with the time set to the specified hours and minutes.
- */
- public Time(final BusinessObject parent, final int hour, final int minute) {
- super(parent);
- setValue(hour, minute);
- }
-
- /*
- * Create a Time object for storing a time with the time set to the specified time.
- */
- public Time(final BusinessObject parent, final Time time) {
- super(parent);
- date = time.date;
- }
-
- /**
- * Add the specified hours and minutes to this time value.
- */
- public void add(final int hours, final int minutes) {
- Calendar cal = Calendar.getInstance();
-
- cal.setTime(date);
- cal.add(Calendar.MINUTE, minutes);
- cal.add(Calendar.HOUR_OF_DAY, hours);
- setValuesInternal(cal, true);
- }
-
- public Calendar calendarValue() {
- ensureAtLeastPartResolved();
- if (date == null) {
- return null;
- }
-
- Calendar c = Calendar.getInstance();
- c.setTimeZone(timeZone);
- c.setTime(date);
-
- return c;
- }
-
- private void checkTime(final int hour, final int minute, final int second) {
- if ((hour < 0) || (hour > 23)) {
- throw new IllegalArgumentException("Hour must be in the range 0 - 23 inclusive");
- }
-
- if ((minute < 0) || (minute > 59)) {
- throw new IllegalArgumentException("Minute must be in the range 0 - 59 inclusive");
- }
-
- if ((second < 0) || (second > 59)) {
- throw new IllegalArgumentException("Second must be in the range 0 - 59 inclusive");
- }
- }
-
- public void clear() {
- setValuesInternal((Date) null, true);
- }
-
- public void copyObject(final BusinessValueHolder object) {
- if (object == null) {
- clear();
- } else if (!(object instanceof Time)) {
- throw new IllegalArgumentException("Can only copy the value of a Date object");
- } else {
- setValue((Time) object);
- }
- }
-
- /**
- * Returns a Calendar object with the irrelevant field (determined by this objects type) set to zero.
- */
- private Calendar createCalendar() {
- Calendar cal = Calendar.getInstance();
- cal.setTimeZone(timeZone);
-
- // clear all aspects of the time that are not used
- cal.set(Calendar.MILLISECOND, 0);
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.DAY_OF_MONTH, 1);
- cal.clear(Calendar.AM_PM);
- cal.clear(Calendar.HOUR);
- cal.set(Calendar.MONTH, 0);
- cal.set(Calendar.YEAR, 1970);
-
- return cal;
- }
-
- public java.util.Date dateValue() {
- ensureAtLeastPartResolved();
- return (date == null) ? null : date;
- }
-
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof Time)) {
- return false;
- }
- Time object = (Time) obj;
- if (object.isEmpty() && isEmpty()) {
- return true;
- }
- return object.date.equals(date);
- }
-
- /**
- * @deprecated replaced by dateValue
- * @see #dateValue
- */
- public java.util.Date getDate() {
- ensureAtLeastPartResolved();
- return date;
- }
-
- public int getHour() {
- ensureAtLeastPartResolved();
- Calendar c = Calendar.getInstance();
- c.setTimeZone(timeZone);
- c.setTime(date);
- return c.get(Calendar.HOUR);
- }
-
- public int getMinute() {
- ensureAtLeastPartResolved();
- Calendar c = Calendar.getInstance();
- c.setTimeZone(timeZone);
- c.setTime(date);
- return c.get(Calendar.MINUTE);
- }
-
- /**
- * Return true if the date is blank
- */
- public boolean isEmpty() {
- ensureAtLeastPartResolved();
- return date == null;
- }
-
- /**
- * returns true if the time of this object has the same value as the specified time
- */
- public boolean isEqualTo(final Magnitude time) {
- ensureAtLeastPartResolved();
- if (time instanceof Time) {
- return (date == null) ? false : (date.equals(((Time) time).date));
- } else {
- throw new IllegalArgumentException("Parameter must be of type Time");
- }
- }
-
- /**
- * returns true if the time of this object is earlier than the specified time
- */
- public boolean isLessThan(final Magnitude time) {
- ensureAtLeastPartResolved();
- if (time instanceof Time) {
- return (date != null) && !time.isEmpty() && date.before(((Time) time).date);
- } else {
- throw new IllegalArgumentException("Parameter must be of type Time");
- }
- }
-
- /**
- * The number of seconds since midnight.
- */
- public long longValue() {
- ensureAtLeastPartResolved();
- return date.getTime() / 1000;
- }
-
- public void parseUserEntry(final String entry) throws ValueParseException {
- if (entry.trim().equals("")) {
- clear();
- } else {
- String text = entry.trim();
-
- String str = text.toLowerCase();
- Calendar cal = createCalendar();
-
- if (str.equals("now")) {} else if (str.startsWith("+")) {
- int hours;
-
- hours = Integer.valueOf(str.substring(1)).intValue();
- cal.setTime(date);
- cal.add(Calendar.HOUR_OF_DAY, hours);
- } else if (str.startsWith("-")) {
- int hours;
-
- hours = Integer.valueOf(str.substring(1)).intValue();
- cal.setTime(date);
- cal.add(Calendar.HOUR_OF_DAY, -hours);
- } else {
- DateFormat[] formats = new DateFormat[] { LONG_FORMAT, MEDIUM_FORMAT, SHORT_FORMAT, ISO_LONG, ISO_SHORT };
-
- for (int i = 0; i < formats.length; i++) {
- try {
- cal.setTime(formats[i].parse(text));
-
- break;
- } catch (ParseException e) {
- if ((i + 1) == formats.length) {
- throw new ValueParseException("Invalid time '" + text + "' for locale " + Locale.getDefault(), e);
- }
- }
- }
- }
-
- setValuesInternal(cal, true);
- }
- }
-
- /**
- * Reset this time so it contains the current time.
- *
- *
- */
- public void reset() {
- setValue(new Date(clock.getTime()));
- }
-
- public void restoreFromEncodedString(final String data) {
- if (data == null || data.equals("NULL")) {
- setValuesInternal((Date) null, false);
- } else {
- int hour = Integer.valueOf(data.substring(0, 2)).intValue();
- int minute = Integer.valueOf(data.substring(2)).intValue();
- setValue(hour, minute);
- setValuesInternal(hour, minute, false);
- }
- }
-
- public String asEncodedString() {
- Calendar cal = calendarValue();
-
- if (cal == null) {
- return "NULL";
- } else {
- StringBuffer data = new StringBuffer(4);
- int hour = cal.get(Calendar.HOUR_OF_DAY);
- data.append((hour <= 9) ? "0" : "");
- data.append(hour);
-
- int minute = cal.get(Calendar.MINUTE);
- data.append((minute <= 9) ? "0" : "");
- data.append(minute);
-
- return data.toString();
- }
- }
-
- /*
- * Sets this object's time to be the same as the specified hour, minute and second.
- */
- public void setValue(final int hour, final int minute) {
- setValuesInternal(hour, minute, true);
- }
-
- public void setValue(final java.util.Date date) {
- if (date == null) {
- setValuesInternal((Date) null, true);
- } else {
- Calendar cal = Calendar.getInstance();
-
- cal.setTime(date);
- setValuesInternal(cal, true);
- }
- }
-
- public void setValue(final long time) {
- Calendar cal = Calendar.getInstance();
-
- cal.setTime(new Date(time * 1000));
- setValuesInternal(cal, true);
- }
-
- public void setValue(final Time time) {
- if (time == null || time.date == null) {
- setValuesInternal((Date) null, true);
- } else {
- setValuesInternal(new Date(time.date.getTime()), true);
- }
- }
-
- private void setValuesInternal(final int hour, final int minute, final boolean notify) {
- checkTime(hour, minute, 0);
-
- Calendar cal = createCalendar();
- cal.setTimeZone(timeZone);
- cal.set(Calendar.HOUR_OF_DAY, hour);
- cal.set(Calendar.MINUTE, minute);
- setValuesInternal(cal, notify);
- }
-
- private void setValuesInternal(final Calendar cal, final boolean notify) {
- cal.set(Calendar.MILLISECOND, 0);
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.DAY_OF_MONTH, 1);
- cal.set(Calendar.MONTH, 0);
- cal.set(Calendar.YEAR, 1970);
- setValuesInternal(cal.getTime(), notify);
- }
-
- private void setValuesInternal(final java.util.Date date, final boolean notify) {
- if (notify) {
- ensureAtLeastPartResolved();
- }
- this.date = date;
- if (notify) {
- parentChanged();
- }
- }
-
- public Title title() {
- ensureAtLeastPartResolved();
- return new Title((date == null) ? "" : SHORT_FORMAT.format(date));
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/TimePeriod.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/TimePeriod.java b/core/applib/src/main/src-archived/old-valueholders/TimePeriod.java
deleted file mode 100644
index ccf5575..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/TimePeriod.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.BusinessObject;
-import org.apache.isis.application.Title;
-import org.apache.isis.application.value.ValueParseException;
-
-
-public class TimePeriod extends BusinessValueHolder {
- private final Time end = new Time();
- private final Time start = new Time();
-
- public TimePeriod() {
- this((BusinessObject) null);
- }
-
- public TimePeriod(final TimePeriod existing) {
- this(null, existing);
- }
-
- public TimePeriod(final BusinessObject parent) {
- super(parent);
- clear();
- }
-
- public TimePeriod(final BusinessObject parent, final TimePeriod existing) {
- super(parent);
- setValue(existing);
- }
-
- public void clear() {
- clearInternal(true);
- }
-
- private void clearInternal(final boolean notify) {
- if (notify) {
- ensureAtLeastPartResolved();
- }
- start.clear();
- end.clear();
- if (notify) {
- parentChanged();
- }
- }
-
- public void copyObject(final BusinessValueHolder object) {
- if (!(object instanceof TimePeriod)) {
- throw new IllegalArgumentException("Can only copy the value of a TimePeriod object");
- }
-
- TimePeriod tp = (TimePeriod) object;
-
- if (tp.isEmpty()) {
- clear();
- } else {
- setValue(tp);
- }
- }
-
- public boolean endsAfter(final TimePeriod arg) {
- ensureAtLeastPartResolved();
- if (end.isGreaterThan(arg.getEnd())) {
- return true;
- } else {
- return false;
- }
- }
-
- public boolean entirelyContains(final TimePeriod arg) {
- ensureAtLeastPartResolved();
- return arg.getStart().isBetween(start, end) && arg.getEnd().isBetween(start, end);
- }
-
- public Time getEnd() {
- ensureAtLeastPartResolved();
- return end;
- }
-
- public Time getStart() {
- ensureAtLeastPartResolved();
- return start;
- }
-
- public boolean isEmpty() {
- ensureAtLeastPartResolved();
- return (start.isEmpty()) && (end.isEmpty());
- }
-
- public boolean isEqualTo(final TimePeriod arg) {
- ensureAtLeastPartResolved();
- if (start.isEqualTo(arg.getStart()) && end.isEqualTo(arg.getEnd())) {
- return true;
- } else {
- return false;
- }
- }
-
- public boolean isSameAs(final BusinessValueHolder object) {
- ensureAtLeastPartResolved();
- if (object instanceof TimePeriod) {
- TimePeriod tp = (TimePeriod) object;
-
- return (start.isEqualTo(tp.getStart())) && (end.isEqualTo(tp.getEnd()));
- } else {
- return false;
- }
- }
-
- public TimePeriod leadDifference(final TimePeriod arg) {
- TimePeriod lead = new TimePeriod();
-
- if (this.startsBefore(arg)) {
- lead.getStart().setValue(start);
- lead.getEnd().setValue(arg.getStart());
- } else {
- lead.getStart().setValue(arg.getStart());
- lead.getEnd().setValue(start);
- }
-
- return lead;
- }
-
- public TimePeriod overlap(final TimePeriod arg) {
- TimePeriod overlap = new TimePeriod();
- overlap.clear();
-
- if (this.overlaps(arg)) {
- if (arg.getStart().isGreaterThan(start)) {
- overlap.getStart().setValue(arg.getStart());
- } else {
- overlap.getStart().setValue(this.start);
- }
-
- if (arg.getEnd().isLessThan(end)) {
- overlap.getEnd().setValue(arg.getEnd());
- } else {
- overlap.getEnd().setValue(this.end);
- }
- }
-
- // N.B. If no overlap currently creates empty TimePeriod.
- return overlap;
- }
-
- public boolean overlaps(final TimePeriod arg) {
- ensureAtLeastPartResolved();
- if (end.isGreaterThan(arg.getStart()) && start.isLessThan(arg.getEnd())) {
- return true;
- } else {
- return false;
- }
- }
-
- public void parseUserEntry(final String text) throws ValueParseException {
- if (text.trim().equals("")) {
- clear();
- } else {
- int tilde = text.indexOf("~");
-
- Time st = new Time();
- Time et = new Time();
- if (tilde >= 0) {
- st.parseUserEntry(text.substring(0, tilde).trim());
- et.parseUserEntry(text.substring(tilde + 1).trim());
- } else {
- // Not sure how to specify the type of the Exception
- throw new ValueParseException("No tilde found", new Exception());
- }
-
- if (et.isLessThan(st)) {
- throw new ValueParseException("End time before start time", new Exception());
- }
- setValue(st, et);
- }
- }
-
- public void reset() {
- ensureAtLeastPartResolved();
- start.reset();
- end.reset();
- parentChanged();
- }
-
- public void restoreFromEncodedString(final String data) {
- if (data == null || data.equals("NULL")) {
- clearInternal(false);
- } else {
- start.restoreFromEncodedString(data.substring(0, 3));
- end.restoreFromEncodedString(data.substring(4, 7));
- }
- }
-
- public String asEncodedString() {
- ensureAtLeastPartResolved();
- if (start.isEmpty() || end.isEmpty()) {
- return "NULL";
- } else {
- StringBuffer data = new StringBuffer(8);
- data.append(start.asEncodedString());
- data.append(end.asEncodedString());
-
- return data.toString();
- }
- }
-
- public void setValue(final Time start, final Time end) {
- ensureAtLeastPartResolved();
- this.start.setValue(start);
- this.end.setValue(end);
- parentChanged();
- }
-
- public void setValue(final TimePeriod t) {
- setValue(t.getStart(), t.getEnd());
- }
-
- public boolean startsBefore(final TimePeriod arg) {
- ensureAtLeastPartResolved();
- if (start.isLessThan(arg.getStart())) {
- return true;
- } else {
- return false;
- }
- }
-
- public TimePeriod tailDifference(final TimePeriod arg) {
- TimePeriod tail = new TimePeriod();
-
- if (this.endsAfter(arg)) {
- tail.getStart().setValue(arg.getEnd());
- tail.getEnd().setValue(end);
- } else {
- tail.getStart().setValue(end);
- tail.getEnd().setValue(arg.getEnd());
- }
-
- return tail;
- }
-
- public Title title() {
- Title t = new Title(getStart() == null ? "" : getStart().title().toString());
- t.append("~");
- t.append(getEnd() == null ? "" : getEnd().title().toString());
-
- return t;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/TimePeriodTest.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/TimePeriodTest.java b/core/applib/src/main/src-archived/old-valueholders/TimePeriodTest.java
deleted file mode 100644
index 651ec7e..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/TimePeriodTest.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.value.ValueParseException;
-
-import java.util.Locale;
-
-
-public class TimePeriodTest extends ValueTestCase {
- static {
- Locale.setDefault(Locale.UK);
- }
-
- private TimePeriod tp1;
- private TimePeriod tp2;
- private TimePeriod tp3;
-
- protected void setUp() throws Exception {
- super.setUp();
-
- tp1 = new TimePeriod();
- tp2 = new TimePeriod();
- tp3 = new TimePeriod();
- }
-
- protected void tearDown() throws Exception {
- tp1 = null;
- }
-
- public void testClear() {
- tp1.clear();
- assertTrue(tp1.title().toString().equals("~"));
- assertTrue(tp1.isEmpty());
- }
-
- public void testOverlaps() throws Exception {
- tp1.parseUserEntry("09:00 ~ 17:00");
- tp2.parseUserEntry("11:00 ~ 18:00");
- assertTrue(tp1.overlaps(tp2));
- assertTrue(tp1.startsBefore(tp2));
- assertFalse(tp2.startsBefore(tp1));
- assertTrue(tp2.endsAfter(tp1));
- assertFalse(tp1.endsAfter(tp2));
- tp3 = tp1.overlap(tp2);
- assertTrue(tp3.title().toString().equals("11:00 ~ 17:00"));
- tp3 = tp1.leadDifference(tp2);
- assertTrue(tp3.title().toString().equals("09:00 ~ 11:00"));
- tp3 = tp2.leadDifference(tp1);
- assertTrue(tp3.title().toString().equals("09:00 ~ 11:00"));
- tp3 = tp1.tailDifference(tp2);
- assertTrue(tp3.title().toString().equals("17:00 ~ 18:00"));
- tp3 = tp2.tailDifference(tp1);
- assertTrue(tp3.title().toString().equals("17:00 ~ 18:00"));
-
- tp1.parseUserEntry("09:00 ~ 13:00");
- tp2.parseUserEntry("14:00 ~ 18:00");
- assertFalse(tp1.overlaps(tp2));
- assertFalse(tp2.overlaps(tp1));
-
- tp1.parseUserEntry("09:00 ~ 13:00");
- tp2.parseUserEntry("13:00 ~ 18:00");
- assertFalse(tp1.overlaps(tp2));
- assertFalse(tp2.overlaps(tp1));
-
- tp1.parseUserEntry("~17:00");
- tp2.parseUserEntry("15:15~");
-
- // May want to revise code to make following assertion true.
- assertFalse(tp2.overlaps(tp1));
- tp3 = tp1.overlap(tp2);
- assertTrue(tp3.title().toString().equals("~"));
- }
-
- public void testParse() throws Exception {
- tp1.parseUserEntry("09:00 ~ 17:00");
- assertEquals(Time.HOUR * 9, tp1.getStart().longValue());
- assertEquals(Time.HOUR * 17, tp1.getEnd().longValue());
- tp1.parseUserEntry("11:00 ~ 13:15");
- assertEquals("11:00 ~ 13:15", tp1.title().toString());
- tp1.parseUserEntry("7:00~19:12");
- assertEquals("07:00 ~ 19:12", tp1.title().toString());
-
- try {
- tp1.parseUserEntry("hgjuiy");
- fail();
- } catch (ValueParseException expected) {}
-
- try {
- tp1.parseUserEntry("8:16 09:00");
- fail();
- } catch (ValueParseException expected) {}
-
- try {
- tp1.parseUserEntry("rtyu~ghjk");
- fail();
- } catch (ValueParseException expected) {}
-
- try {
- tp1.parseUserEntry("13:05 ~ 13:01");
- fail();
- } catch (ValueParseException e) {
- assertTrue(e.getMessage().equals("End time before start time"));
- }
-
- tp1.parseUserEntry("13:05~");
- assertTrue(tp1.title().toString().equals("13:05 ~"));
- tp1.parseUserEntry("~19:15 ");
- assertTrue(tp1.title().toString().equals("~ 19:15"));
- }
-
- public void testSaveAndRestore() throws Exception {
- tp1.parseUserEntry("09:00 ~ 17:00");
-
- String s = tp1.asEncodedString();
- assertTrue(s.equals("09001700"));
- tp2.restoreFromEncodedString(s);
- assertTrue(tp2.title().toString().equals("09:00 ~ 17:00"));
- assertTrue(tp2.isSameAs(tp1));
- }
-
- public void testSaveStringLength() {
- tp1.reset();
- assertTrue(tp1.asEncodedString().length() == 8);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/TimeStamp.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/TimeStamp.java b/core/applib/src/main/src-archived/old-valueholders/TimeStamp.java
deleted file mode 100644
index 024881e..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/TimeStamp.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.ApplicationException;
-import org.apache.isis.application.BusinessObject;
-import org.apache.isis.application.Clock;
-import org.apache.isis.application.Title;
-import org.apache.isis.application.value.ValueParseException;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-
-
-/**
- * Value object representing a date and time value.
- * <p>
- * NOTE: this class currently does not support about listeners
- * </p>
- */
-public class TimeStamp extends Magnitude {
- // TODO check the ISO representations
- private static final DateFormat ISO_LONG = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
- // private static final DateFormat ISO_SHORT = new SimpleDateFormat("yyyyMMdd'T'HHmmssSSS");
-
- private boolean isNull = true;
- private java.util.Date date;
- private static Clock clock;
-
- public static void setClock(final Clock clock) {
- TimeStamp.clock = clock;
- }
-
- /**
- * Create a Time object for storing a timeStamp set to the current time.
- */
- public TimeStamp() {
- this((BusinessObject) null);
- }
-
- /**
- * Create a Time object for storing a timeStamp set to the specified time.
- */
- public TimeStamp(final TimeStamp timeStamp) {
- this(null, timeStamp);
- }
-
- /**
- * Create a Time object for storing a timeStamp set to the current time.
- */
- public TimeStamp(final BusinessObject parent) {
- super(parent);
- if (clock == null) {
- throw new ApplicationException("Clock not set up");
- }
- reset();
- }
-
- /**
- * Create a Time object for storing a timeStamp set to the specified time.
- */
- public TimeStamp(final BusinessObject parent, final TimeStamp timeStamp) {
- super(parent);
- date = timeStamp.date;
- isNull = timeStamp.isNull;
- }
-
- public void clear() {
- setValuesInternal(date, true, true);
- }
-
- public void copyObject(final BusinessValueHolder object) {
- if (!(object instanceof TimeStamp)) {
- throw new IllegalArgumentException("Can only copy the value of a TimeStamp object");
- }
- TimeStamp ts = (TimeStamp) object;
- setValuesInternal(ts.date, ts.isNull, true);
- }
-
- /**
- * Returns a Calendar object with the irrelevant field (determined by this objects type) set to zero.
- */
- private Calendar createCalendar() {
- Calendar cal = Calendar.getInstance();
- return cal;
- }
-
- public java.util.Date dateValue() {
- ensureAtLeastPartResolved();
- return isNull ? null : date;
- }
-
- /**
- * Return true if the time stamp is blank
- */
- public boolean isEmpty() {
- ensureAtLeastPartResolved();
- return isNull;
- }
-
- /**
- * returns true if the time stamp of this object has the same value as the specified time
- */
- public boolean isEqualTo(final Magnitude timeStamp) {
- ensureAtLeastPartResolved();
- if (timeStamp instanceof TimeStamp) {
- if (isNull) {
- return timeStamp.isEmpty();
- }
-
- return this.date.equals(((TimeStamp) timeStamp).date);
- } else {
- throw new IllegalArgumentException("Parameter must be of type Time");
- }
- }
-
- /**
- * returns true if the timeStamp of this object is earlier than the specified timeStamp
- */
- public boolean isLessThan(final Magnitude timeStamp) {
- ensureAtLeastPartResolved();
- if (timeStamp instanceof TimeStamp) {
- return !isNull && !timeStamp.isEmpty() && date.before(((TimeStamp) timeStamp).date);
- } else {
- throw new IllegalArgumentException("Parameter must be of type Time");
- }
- }
-
- public long longValue() {
- ensureAtLeastPartResolved();
- return date.getTime();
- }
-
- public void parseUserEntry(final String text) throws ValueParseException {}
-
- /**
- * Reset this time so it contains the current time.
- */
- public void reset() {
- setValuesInternal(new Date(clock.getTime()), false, true);
- }
-
- private void setValuesInternal(final java.util.Date value, final boolean isNull, final boolean notify) {
- if (notify) {
- ensureAtLeastPartResolved();
- }
- this.date = value;
- this.isNull = isNull;
- if (notify) {
- parentChanged();
- }
- }
-
- public Title title() {
- ensureAtLeastPartResolved();
- return new Title(isNull ? "" : ISO_LONG.format(date));
- }
-
- public Calendar calendarValue() {
- ensureAtLeastPartResolved();
- if (isNull) {
- return null;
- }
-
- Calendar c = Calendar.getInstance();
- c.setTime(date);
-
- return c;
- }
-
- public void restoreFromEncodedString(final String data) {
- if (data == null || data.equals("NULL")) {
- setValuesInternal(date, true, false);
- } else {
- int year = Integer.valueOf(data.substring(0, 4)).intValue();
- int month = Integer.valueOf(data.substring(4, 6)).intValue();
- int day = Integer.valueOf(data.substring(6, 8)).intValue();
- int hour = Integer.valueOf(data.substring(8, 10)).intValue();
- int minute = Integer.valueOf(data.substring(10, 12)).intValue();
- int second = Integer.valueOf(data.substring(12, 14)).intValue();
- int millisecond = Integer.valueOf(data.substring(14, 17)).intValue();
-
- Calendar cal = createCalendar();
-
- cal.set(Calendar.DAY_OF_MONTH, day);
- cal.set(Calendar.MONTH, month - 1);
- cal.set(Calendar.YEAR, year);
- cal.set(Calendar.HOUR_OF_DAY, hour);
- cal.set(Calendar.MINUTE, minute);
- cal.set(Calendar.SECOND, second);
- cal.set(Calendar.MILLISECOND, millisecond);
- setValuesInternal(cal.getTime(), false, true);
- }
- }
-
- public String asEncodedString() {
- if (isEmpty()) {
- return "NULL";
- } else {
- Calendar cal = calendarValue();
- StringBuffer data = new StringBuffer(8);
- String year = String.valueOf(cal.get(Calendar.YEAR));
- data.append("0000".substring(0, 4 - year.length()));
- data.append(year);
-
- int month = cal.get(Calendar.MONTH) + 1;
- data.append((month <= 9) ? "0" : "");
- data.append(month);
-
- int day = cal.get(Calendar.DAY_OF_MONTH);
- data.append((day <= 9) ? "0" : "");
- data.append(day);
-
- int hour = cal.get(Calendar.HOUR_OF_DAY);
- data.append((hour <= 9) ? "0" : "");
- data.append(hour);
-
- int minute = cal.get(Calendar.MINUTE);
- data.append((minute <= 9) ? "0" : "");
- data.append(minute);
-
- int second = cal.get(Calendar.SECOND);
- data.append((second <= 9) ? "0" : "");
- data.append(second);
-
- int millisecond = cal.get(Calendar.MILLISECOND);
- data.append((millisecond <= 99) ? "0" : "");
- data.append((millisecond <= 9) ? "0" : "");
- data.append(millisecond);
-
- return data.toString();
- }
- }
-
- public String toString() {
- return title() + " " + longValue() + " [TimeStamp]";
- }
-
- public void setValue(final TimeStamp ts) {
- if ((ts == null)) {
- this.clear();
- } else {
- setValuesInternal(ts.date, ts.isNull, true);
- }
- }
-
- public void setValue(final java.util.Date date) {
- setValuesInternal(date, date == null, true);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/TimeTests.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/TimeTests.java b/core/applib/src/main/src-archived/old-valueholders/TimeTests.java
deleted file mode 100644
index 5625a43..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/TimeTests.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.value.ValueParseException;
-
-
-public class TimeTests extends ValueTestCase {
- private Time t;
-
- public void testTimeConstructors() {
- assertEquals("Two identically created objects", t.dateValue(), new Time(10, 40).dateValue());
- assertEquals("One object created from another", t.dateValue(), new Time(t).dateValue());
- }
-
- public void testSetTime() {
- Time t2 = new Time();
- t2.setValue(10, 40);
- assertEquals("Set with values", t.dateValue(), t2.dateValue());
- Time t3 = new Time();
- t3.setValue(10, 40);
- assertEquals("Set with values", t.dateValue(), t3.dateValue());
- }
-
- public void testGetHour() {
- assertEquals(10, t.getHour());
- }
-
- public void testGetMinute() {
- assertEquals(40, t.getMinute());
- }
-
- public void testZero() {
- assertEquals("Zero value", 0, Time.getZero());
- }
-
- public void testGetValue() {
- Time t2 = new Time(0, 0);
- assertEquals("new zero value time", 0, t2.longValue());
-
- t2 = new Time();
- t2.setValue(0, 0);
- assertEquals("set to zero", 0, t2.longValue());
-
- Time t3 = new Time(0, 1);
- assertEquals(t2.longValue() + 60, t3.longValue());
-
- assertEquals(10 * 3600 + 40 * 60, t.longValue());
- }
-
- public void testClear() {
- assertTrue("After creation should not be empty", !t.isEmpty());
- t.clear();
- assertTrue("After clear should be empty", t.isEmpty());
- }
-
- public void testDefaultTime() throws InterruptedException {
- Time t1 = new Time();
- assertEquals("temp", t1.dateValue(), new Time().dateValue());
- }
-
- public void testParseTime() throws ValueParseException {
- t.parseUserEntry("0:00");
- assertEquals("00:00", 0, t.longValue());
-
- t.parseUserEntry("0:01");
- assertEquals("00:00", 60, t.longValue());
-
- t.parseUserEntry("11:35 AM");
- assertEquals("11:35", 11 * 3600 + 35 * 60, t.longValue());
-
- t.parseUserEntry("12:50");
- assertEquals("12:50", 12 * 3600 + 50 * 60, t.longValue());
-
- t.parseUserEntry("14:45");
- assertEquals("14:45", 14 * 3600 + 45 * 60, t.longValue());
-
- t.parseUserEntry("22:55");
- assertEquals("22:55", 22 * 3600 + 55 * 60, t.longValue());
- t.parseUserEntry("23:00");
- assertEquals("23:00", 23 * 3600, t.longValue());
-
- t.parseUserEntry("23:59");
- assertEquals("23:59", 23 * 3600 + 59 * 60, t.longValue());
- }
-
- public void testIsEqualsTo() {
- Time t2 = new Time(0, 0);
- t.clear();
-
- assertTrue("When object is empty and is compared with non-empty", !t2.isEqualTo(t));
- assertTrue("When object is non-empty and is compared with empty", !t.isEqualTo(t2));
- t2.clear();
- assertTrue("When both objects are empty", !t.isEqualTo(t2));
-
- t.setValue(1, 15);
- t2.setValue(1, 00);
- assertTrue("When times are different", !t.isEqualTo(t2));
-
- t2.setValue(1, 15);
- assertTrue("When times are same", t.isEqualTo(t2));
- }
-
- public void testParseAdd() throws ValueParseException {
- assertEquals("10:40", 10 * 3600 + 40 * 60, t.longValue());
-
- t.parseUserEntry("+1");
- assertEquals("11:40", 11 * 3600 + 40 * 60, t.longValue());
-
- t.parseUserEntry("+1");
- assertEquals("12:40", 12 * 3600 + 40 * 60, t.longValue());
-
- t.parseUserEntry("+22");
- assertEquals("10:40", 10 * 3600 + 40 * 60, t.longValue());
-
- }
-
- public void testSave() throws Exception {
- assertEquals("1040", t.asEncodedString());
-
- t.setValue(6, 25);
- assertEquals("0625", t.asEncodedString());
-
- t.setValue(23, 55);
- assertEquals("2355", t.asEncodedString());
- }
-
- public void testSaveEmpty() throws Exception {
- t.clear();
- assertEquals("NULL", t.asEncodedString());
- }
-
- public void testRestore() {
- t.restoreFromEncodedString("0805");
- assertEquals(8 * 3600 + 5 * 60, t.longValue());
-
- t.restoreFromEncodedString("2359");
- assertEquals(23 * 3600 + 59 * 60, t.longValue());
- }
-
- public void testRestoreEmpty() {
- t.restoreFromEncodedString("NULL");
- assertTrue(t.isEmpty());
- }
-
- protected void setUp() throws Exception {
- super.setUp();
-
- t = new Time(10, 40);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/URLString.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/URLString.java b/core/applib/src/main/src-archived/old-valueholders/URLString.java
deleted file mode 100644
index 82afca7..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/URLString.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.BusinessObject;
-import org.apache.isis.application.Title;
-import org.apache.isis.application.value.ValueParseException;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-
-/**
- * value object to represent an URL.
- * <p>
- * NOTE: this class currently does not support about listeners
- * </p>
- */
-public class URLString extends BusinessValueHolder {
- private String urlString;
-
- public URLString() {
- this(null, "");
- }
-
- public URLString(final String urlString) {
- this(null, urlString);
- }
-
- public URLString(final URLString urlString) {
- this(null, urlString);
- }
-
- public URLString(final BusinessObject parent) {
- this(parent, "");
- }
-
- public URLString(final BusinessObject parent, final String urlString) {
- super(parent);
- this.urlString = urlString;
- }
-
- public URLString(final BusinessObject parent, final URLString urlString) {
- super(parent);
- this.urlString = new String(urlString.toString());
- }
-
- public void clear() {
- setValuesInternal(null, true);
- }
-
- /**
- * Copies the specified object's contained data to this instance. param object the object to copy the data
- * from
- */
- public void copyObject(final BusinessValueHolder object) {
- if (!(object instanceof URLString)) {
- throw new IllegalArgumentException("Can only copy the value of a URLString object");
- }
- setValue((URLString) object);
- }
-
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof URLString)) {
- return false;
- }
- URLString object = (URLString) obj;
- if (object.isEmpty() && isEmpty()) {
- return true;
- }
- return object.urlString.equals(urlString);
- }
-
- public String getObjectHelpText() {
- return "A URLString object.";
- }
-
- public boolean isEmpty() {
- ensureAtLeastPartResolved();
- return urlString == null;
- }
-
- /**
- * Compares the url string to see if the contain the same text if the specified object is a
- * <code>URLString</code> object else returns false.
- *
- * @see BusinessValueHolder#isSameAs(BusinessValueHolder)
- */
- public boolean isSameAs(final BusinessValueHolder object) {
- ensureAtLeastPartResolved();
- if (object instanceof URLString) {
- URLString other = (URLString) object;
- if (urlString == null) {
- return other.urlString == null;
- }
- return urlString.equals(other.urlString);
- } else {
- return false;
- }
-
- }
-
- public void parseUserEntry(final String urlString) throws ValueParseException {
- try {
- new URL(urlString);
- setValue(urlString);
- } catch (MalformedURLException e) {
- throw new ValueParseException("Invalid URL", e);
- }
- }
-
- /**
- * Reset this url string so it contains an empty string, i.e. "".
- */
- public void reset() {
- setValue("");
- }
-
- public void restoreFromEncodedString(final String data) {
- if (data == null || data.equals("NULL")) {
- setValuesInternal(null, false);
- } else {
- setValuesInternal(data, false);
- }
- }
-
- public String asEncodedString() {
- return isEmpty() ? "NULL" : urlString;
- }
-
- public void setValue(final String urlString) {
- setValuesInternal(urlString, true);
- }
-
- public void setValue(final URLString urlString) {
- setValuesInternal(urlString.urlString, true);
- }
-
- private void setValuesInternal(final String value, final boolean notify) {
- if (notify) {
- ensureAtLeastPartResolved();
- }
- this.urlString = value;
- if (notify) {
- parentChanged();
- }
- }
-
- public String stringValue() {
- ensureAtLeastPartResolved();
- return urlString;
- }
-
- public Title title() {
- ensureAtLeastPartResolved();
- return new Title(urlString);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/ValueTestCase.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/ValueTestCase.java b/core/applib/src/main/src-archived/old-valueholders/ValueTestCase.java
deleted file mode 100644
index 5dd5d3b..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/ValueTestCase.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.system.TestClock;
-
-import junit.framework.TestCase;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public abstract class ValueTestCase extends TestCase {
- protected void setUp() throws Exception {
- Logger.getRootLogger().setLevel(Level.OFF);
- // new MockObjectSpecificationLoader();
- new TestClock();
- }
-}
[4/4] git commit: ISIS-518,
ISIS-519: deprecating applib's Filter and deleting archived code.
Posted by da...@apache.org.
ISIS-518, ISIS-519: deprecating applib's Filter and deleting archived code.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/52912061
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/52912061
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/52912061
Branch: refs/heads/master
Commit: 52912061ff707652294beefe2806056a9ff89bf6
Parents: 91df997
Author: Dan Haywood <da...@apache.org>
Authored: Fri Sep 6 18:10:51 2013 +0100
Committer: Dan Haywood <da...@apache.org>
Committed: Fri Sep 6 18:10:51 2013 +0100
----------------------------------------------------------------------
.../isis/applib/AbstractContainedObject.java | 71 ++-
.../isis/applib/DomainObjectContainer.java | 59 ++-
.../org/apache/isis/applib/filter/Filter.java | 5 +
.../org/apache/isis/applib/filter/Filters.java | 5 +
.../isis/applib/fixtures/AbstractFixture.java | 6 +-
.../org/apache/isis/applib/query/Query.java | 13 +-
.../AbstractGenericFactoryAndRepository.java | 202 --------
.../DomainGenericObjectContainer.java | 176 -------
.../src-archived/annotations/BusinessKey.java | 44 --
.../main/src-archived/annotations/Cached.java | 40 --
.../src-archived/annotations/Searchable.java | 48 --
.../src-archived/interfaces/Aggregated.java | 30 --
.../main/src-archived/interfaces/Cached.java | 29 --
.../old-valueholders/BusinessValueHolder.java | 97 ----
.../src-archived/old-valueholders/Case.java | 36 --
.../src-archived/old-valueholders/Color.java | 173 -------
.../old-valueholders/ColorTest.java | 40 --
.../src-archived/old-valueholders/Date.java | 515 -------------------
.../old-valueholders/DatePeriod.java | 252 ---------
.../old-valueholders/DatePeriodTest.java | 143 -----
.../src-archived/old-valueholders/DateTest.java | 93 ----
.../src-archived/old-valueholders/DateTime.java | 461 -----------------
.../old-valueholders/DateTimeTest.java | 86 ----
.../old-valueholders/FloatingPointNumber.java | 257 ---------
.../src-archived/old-valueholders/Label.java | 55 --
.../src-archived/old-valueholders/Logical.java | 204 --------
.../old-valueholders/Magnitude.java | 81 ---
.../src-archived/old-valueholders/Money.java | 323 ------------
.../old-valueholders/MoneyTest.java | 59 ---
.../old-valueholders/MultilineTextString.java | 115 -----
.../MultilineTextStringTests.java | 53 --
.../src-archived/old-valueholders/Option.java | 228 --------
.../src-archived/old-valueholders/Password.java | 139 -----
.../old-valueholders/Percentage.java | 260 ----------
.../old-valueholders/PhoneNumber.java | 40 --
.../src-archived/old-valueholders/Quantity.java | 68 ---
.../src-archived/old-valueholders/RtfValue.java | 193 -------
.../old-valueholders/SerialNumber.java | 155 ------
.../old-valueholders/SimpleState.java | 186 -------
.../old-valueholders/TestClock.java | 68 ---
.../old-valueholders/TextString.java | 380 --------------
.../old-valueholders/TextStringTests.java | 45 --
.../src-archived/old-valueholders/Time.java | 469 -----------------
.../old-valueholders/TimePeriod.java | 266 ----------
.../old-valueholders/TimePeriodTest.java | 144 ------
.../old-valueholders/TimeStamp.java | 270 ----------
.../old-valueholders/TimeTests.java | 170 ------
.../old-valueholders/URLString.java | 179 -------
.../old-valueholders/ValueTestCase.java | 39 --
.../old-valueholders/WholeNumber.java | 414 ---------------
.../old-valueholders/WholeNumberTests.java | 47 --
.../old-valueholders/XmlString.java | 43 --
.../container/DomainObjectContainerDefault.java | 41 +-
53 files changed, 167 insertions(+), 7448 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/java/org/apache/isis/applib/AbstractContainedObject.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/AbstractContainedObject.java b/core/applib/src/main/java/org/apache/isis/applib/AbstractContainedObject.java
index ec61234..d5307cd 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/AbstractContainedObject.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/AbstractContainedObject.java
@@ -21,6 +21,8 @@ package org.apache.isis.applib;
import java.util.List;
+import com.google.common.base.Predicate;
+
import org.apache.isis.applib.annotation.Aggregated;
import org.apache.isis.applib.annotation.Hidden;
import org.apache.isis.applib.filter.Filter;
@@ -68,9 +70,9 @@ public abstract class AbstractContainedObject {
protected <T> T newAggregatedInstance(final Object parent, final Class<T> ofType) {
return getContainer().newAggregatedInstance(parent, ofType);
}
- // }}
+
+ // //////////////////////////////////////
- // {{ allInstances, allMatches
/**
* Convenience method that delegates to {@link DomainObjectContainer}.
*
@@ -80,11 +82,25 @@ public abstract class AbstractContainedObject {
return getContainer().allInstances(ofType, range);
}
+ // //////////////////////////////////////
+
+ /**
+ * Convenience method that delegates to {@link DomainObjectContainer}.
+ *
+ * @see DomainObjectContainer#allMatches(Class, Predicate, long...)
+ */
+ protected <T> List<T> allMatches(final Class<T> ofType, final Predicate<? super T> predicate, long... range) {
+ return getContainer().allMatches(ofType, predicate, range);
+ }
+
/**
* Convenience method that delegates to {@link DomainObjectContainer}.
*
* @see DomainObjectContainer#allMatches(Class, Filter, long...)
+ *
+ * @deprecated - use {@link #allMatches(Class, Predicate, long...)}
*/
+ @Deprecated
protected <T> List<T> allMatches(final Class<T> ofType, final Filter<? super T> filter, long... range) {
return getContainer().allMatches(ofType, filter, range);
}
@@ -116,18 +132,30 @@ public abstract class AbstractContainedObject {
return getContainer().allMatches(query);
}
- // }}
+ // //////////////////////////////////////
+
+ /**
+ * Convenience method that delegates to {@link DomainObjectContainer}.
+ *
+ * @see DomainObjectContainer#firstMatch(Class, Predicate)
+ *
+ */
+ protected <T> T firstMatch(final Class<T> ofType, final Predicate<T> predicate) {
+ return getContainer().firstMatch(ofType, predicate);
+ }
- // {{ firstMatch
/**
* Convenience method that delegates to {@link DomainObjectContainer}.
*
* @see DomainObjectContainer#firstMatch(Class, Filter)
+ *
+ * @deprecated - use {@link #firstMatch(Class, Predicate)}
*/
+ @Deprecated
protected <T> T firstMatch(final Class<T> ofType, final Filter<T> filter) {
return getContainer().firstMatch(ofType, filter);
}
-
+
/**
* Convenience method that delegates to {@link DomainObjectContainer}.
*
@@ -155,18 +183,30 @@ public abstract class AbstractContainedObject {
return getContainer().firstMatch(query);
}
- // }}
+ // //////////////////////////////////////
+
+
+ /**
+ * Convenience method that delegates to {@link DomainObjectContainer}.
+ *
+ * @see DomainObjectContainer#uniqueMatch(Class, Predicate)
+ */
+ protected <T> T uniqueMatch(final Class<T> ofType, final Predicate<T> predicate) {
+ return getContainer().uniqueMatch(ofType, predicate);
+ }
- // {{ uniqueMatch
/**
* Convenience method that delegates to {@link DomainObjectContainer}.
*
* @see DomainObjectContainer#uniqueMatch(Class, Filter)
+ *
+ * @deprecated - use {@link #uniqueMatch(Class, Predicate)}
*/
+ @Deprecated
protected <T> T uniqueMatch(final Class<T> ofType, final Filter<T> filter) {
return getContainer().uniqueMatch(ofType, filter);
}
-
+
/**
* Convenience method that delegates to {@link DomainObjectContainer}.
*
@@ -194,9 +234,8 @@ public abstract class AbstractContainedObject {
return getContainer().uniqueMatch(query);
}
- // }}
+ // //////////////////////////////////////
- // {{ isValid, validate
/**
* Convenience methods that delegates to {@link DomainObjectContainer}.
*
@@ -215,9 +254,8 @@ public abstract class AbstractContainedObject {
return getContainer().validate(domainObject);
}
- // }}
+ // //////////////////////////////////////
- // {{ isPersistent, persist, remove
/**
* Whether the provided object is persistent.
*/
@@ -262,9 +300,8 @@ public abstract class AbstractContainedObject {
return persistentDomainObject;
}
- // }}
+ // //////////////////////////////////////
- // {{ Error/Warning Methods
/**
* Display the specified message to the user, in a non-intrusive fashion.
*/
@@ -288,16 +325,14 @@ public abstract class AbstractContainedObject {
getContainer().raiseError(message);
}
- // }}
+ // //////////////////////////////////////
- // {{ Security Methods
protected UserMemento getUser() {
return getContainer().getUser();
}
- // }}
+ // //////////////////////////////////////
- // {{ Injected: Container
/**
* @uml.property name="container"
* @uml.associationEnd
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/java/org/apache/isis/applib/DomainObjectContainer.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/DomainObjectContainer.java b/core/applib/src/main/java/org/apache/isis/applib/DomainObjectContainer.java
index 4a1b77d..afe968e 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/DomainObjectContainer.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/DomainObjectContainer.java
@@ -21,6 +21,8 @@ package org.apache.isis.applib;
import java.util.List;
+import com.google.common.base.Predicate;
+
import org.apache.isis.applib.annotation.Aggregated;
import org.apache.isis.applib.filter.Filter;
import org.apache.isis.applib.query.Query;
@@ -291,6 +293,26 @@ public interface DomainObjectContainer {
/**
* Returns all the instances of the specified type (including subtypes) that
+ * the predicate object accepts. If the optional range parameters are used, the
+ * dataset returned starts from (0 based) index, and consists of only up to
+ * count items.
+ *
+ * <p>
+ * If there are no instances the list will be empty. This method creates a
+ * new {@link List} object each time it is called so the caller is free to
+ * use or modify the returned {@link List}, but the changes will not be
+ * reflected back to the repository.
+ *
+ * <p>
+ * This method is useful during exploration/prototyping, but you may want to
+ * use {@link #allMatches(Query)} for production code.
+ *
+ * @param range 2 longs, specifying 0-based start and count.
+ */
+ public <T> List<T> allMatches(final Class<T> ofType, final Predicate<? super T> predicate, long... range);
+
+ /**
+ * Returns all the instances of the specified type (including subtypes) that
* the filter object accepts. If the optional range parameters are used, the
* dataset returned starts from (0 based) index, and consists of only up to
* count items.
@@ -306,7 +328,10 @@ public interface DomainObjectContainer {
* use {@link #allMatches(Query)} for production code.
*
* @param range 2 longs, specifying 0-based start and count.
+ *
+ * @deprecated - use {@link #allMatches(Class, Predicate, long...)} instead.
*/
+ @Deprecated
public <T> List<T> allMatches(final Class<T> ofType, final Filter<? super T> filter, long... range);
/**
@@ -361,6 +386,18 @@ public interface DomainObjectContainer {
*/
<T> List<T> allMatches(Query<T> query);
+ // //////////////////////////////////////
+
+ /**
+ * Returns the first instance of the specified type (including subtypes)
+ * that matches the supplied {@link Predicate}, or <tt>null</tt> if none.
+ *
+ * <p>
+ * This method is useful during exploration/prototyping, but you may want to
+ * use {@link #firstMatch(Query)} for production code.
+ */
+ public <T> T firstMatch(final Class<T> ofType, final Predicate<T> predicate);
+
/**
* Returns the first instance of the specified type (including subtypes)
* that matches the supplied {@link Filter}, or <tt>null</tt> if none.
@@ -368,7 +405,10 @@ public interface DomainObjectContainer {
* <p>
* This method is useful during exploration/prototyping, but you may want to
* use {@link #firstMatch(Query)} for production code.
+ *
+ * @deprecated - use {@link #firstMatch(Class, Predicate)}
*/
+ @Deprecated
public <T> T firstMatch(final Class<T> ofType, final Filter<T> filter);
/**
@@ -409,13 +449,30 @@ public interface DomainObjectContainer {
* This method is useful during exploration/prototyping, but you may want to
* use {@link #uniqueMatch(Query)} for production code.
*/
- public <T> T uniqueMatch(final Class<T> ofType, final Filter<T> filter);
+ public <T> T uniqueMatch(final Class<T> ofType, final Predicate<T> predicate);
/**
* Find the only instance of the specified type (including subtypes) that
* has the specified title.
*
* <p>
+ * If no instance is found then <tt>null</tt> will be return, while if there
+ * is more that one instances a run-time exception will be thrown.
+ *
+ * <p>
+ * This method is useful during exploration/prototyping, but you may want to
+ * use {@link #uniqueMatch(Query)} for production code.
+ *
+ * @deprecated - use {@link #uniqueMatch(Class, Predicate)}
+ */
+ @Deprecated
+ public <T> T uniqueMatch(final Class<T> ofType, final Filter<T> filter);
+
+ /**
+ * Find the only instance of the specified type (including subtypes) that
+ * has the specified title.
+ *
+ * <p>
* If no instance is found then <tt>null</tt> will be returned, while if
* there is more that one instances a run-time exception will be thrown.
*
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/java/org/apache/isis/applib/filter/Filter.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/filter/Filter.java b/core/applib/src/main/java/org/apache/isis/applib/filter/Filter.java
index d8cade8..cc1edb8 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/filter/Filter.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/filter/Filter.java
@@ -19,6 +19,8 @@
package org.apache.isis.applib.filter;
+import com.google.common.base.Predicate;
+
/**
* For use by repository implementations to allow a set of objects returned by a
@@ -31,7 +33,10 @@ package org.apache.isis.applib.filter;
* an already-filtered set of rows. (For example, a Hibernate-based ObjectStore
* would accept a representation of a HQL query; an XML-based objectstore might
* accept an XPath query, etc.)
+ *
+ * @deprecated - use {@link Predicate} instead.
*/
+@Deprecated
public interface Filter<T> {
/**
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/java/org/apache/isis/applib/filter/Filters.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/filter/Filters.java b/core/applib/src/main/java/org/apache/isis/applib/filter/Filters.java
index 96a08c0..ae240a9 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/filter/Filters.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/filter/Filters.java
@@ -20,7 +20,12 @@
package org.apache.isis.applib.filter;
import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+/**
+ * @deprecated - use {@link Predicate} and {@link Predicates} instead.
+ */
+@Deprecated
public final class Filters {
private Filters() {
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/java/org/apache/isis/applib/fixtures/AbstractFixture.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/fixtures/AbstractFixture.java b/core/applib/src/main/java/org/apache/isis/applib/fixtures/AbstractFixture.java
index 01dec69..9b49d6d 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/fixtures/AbstractFixture.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/fixtures/AbstractFixture.java
@@ -23,6 +23,8 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import com.google.common.base.Predicate;
+
import org.apache.isis.applib.annotation.Programmatic;
/**
@@ -36,8 +38,8 @@ import org.apache.isis.applib.annotation.Programmatic;
* {@link #setDate(int, int, int)} and {@link #setTime(int, int)}.
* <li>create composite fixtures using {@link #addFixture(Object)}.
* <li>search for existing objects using
- * {@link #firstMatch(Class, org.apache.isis.applib.Filter)} or
- * {@link #uniqueMatch(Class, org.apache.isis.applib.Filter)} (and various
+ * {@link #firstMatch(Class, Predicate)} or
+ * {@link #uniqueMatch(Class, Predicate)} (and various
* overloads thereof).
* </ul>
*
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/java/org/apache/isis/applib/query/Query.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/query/Query.java b/core/applib/src/main/java/org/apache/isis/applib/query/Query.java
index 37f8f68..cfb5f20 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/query/Query.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/query/Query.java
@@ -21,8 +21,9 @@ package org.apache.isis.applib.query;
import java.io.Serializable;
+import com.google.common.base.Predicate;
+
import org.apache.isis.applib.DomainObjectContainer;
-import org.apache.isis.applib.filter.Filter;
/**
* For use by repository implementations, representing the values of a query.
@@ -33,15 +34,15 @@ import org.apache.isis.applib.filter.Filter;
* <p>
* Implementations are expected to implement the {@link #getStart()} and
* {@link #getCount()} methods, which are used to support range / paging
- * the data. Retutned result sets are expected to start from index "start",
+ * the data. Returned result sets are expected to start from index "start",
* and no more than "count" items are expected.
* <p>
* <b>Note:</b> that not every object store will necessarily support this
* interface. In particular, the in-memory object store does not. For this, you
- * can use the {@link Filter} interface to similar effect, for example in
- * {@link DomainObjectContainer#allMatches(Class, Filter, long...)}). Note that the
- * filtering is done within the {@link DomainObjectContainer} rather than being
- * pushed back to the object store.
+ * can use the {@link Predicate} interface to similar effect, for example in
+ * {@link DomainObjectContainer#allMatches(Class, Predicate, long...)}). Note that the
+ * predicate is applied within the {@link DomainObjectContainer} (ie client-side)
+ * rather than being pushed back to the object store.
*/
public interface Query<T> extends Serializable {
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/AbstractGenericFactoryAndRepository.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/AbstractGenericFactoryAndRepository.java b/core/applib/src/main/src-archived/AbstractGenericFactoryAndRepository.java
deleted file mode 100644
index 51a5657..0000000
--- a/core/applib/src/main/src-archived/AbstractGenericFactoryAndRepository.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.applib.generics;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.isis.applib.AbstractService;
-import org.apache.isis.applib.Filter;
-import org.apache.isis.applib.RepositoryException;
-
-
-public abstract class AbstractGenericFactoryAndRepository extends AbstractService {
-
- private DomainGenericObjectContainer genericContainer;
-
- /**
- * This field is not persisted, nor displayed to the user.
- */
- protected DomainGenericObjectContainer getGenericContainer() {
- return this.genericContainer;
- }
-
- /**
- * Injected by the application container itself.
- */
- public final void setGenericContainer(final DomainGenericObjectContainer container) {
- this.genericContainer = container;
- }
-
-
-
- /**
- * Returns all the instances of the specified type, including instances of any subclasses if the
- * includeSubclasses flag set. If there are no instances the list will be empty. This method creates a new
- * list object each time it is called so the caller is free to use or modify the returned List, but the
- * changes will not be reflected back to the repository.
- */
- protected <T> List<T> allInstances(final Class<T> cls, final boolean includeSubclasses) {
- T[] instances = getGenericContainer().allInstances(cls, includeSubclasses);
- return asList(instances);
- }
-
- /**
- * Returns all the instances of the specified type that the filter object accepts. This method will also
- * search through the instances of any subclasses if the includeSubclasses flag is set. If there are no
- * instances the list will be empty. This method creates a new list object each time it is called so the
- * caller is free to use or modify the returned List, but the changes will not be reflected back to the
- * repository.
- */
- protected <T> List<T> allMatches(final Class<T> cls, final Filter filter, final boolean includeSubclasses) {
- T[] allInstances = getGenericContainer().allInstances(cls, includeSubclasses);
- List<T> filtered = new ArrayList<T>();
- for (int i = 0; i < allInstances.length; i++) {
- T instance = allInstances[i];
- if (filter.accept(instance)) {
- filtered.add(instance);
- }
- }
- return filtered;
- }
-
- /**
- * Returns all the instances of the specified type that match the given object: where any property that is
- * set will be tested and properties that are not set will be ignored. This method will also search though
- * the instances of any subclasses if the includeSubclasses flag is set. If there are no instances the
- * list will be empty. This method creates a new list object each time it is called so the caller is free
- * to use or modify the returned List, but the changes will not be reflected back to the repository.
- */
- protected <T> List<T> allMatches(final Class<T> cls, final Object pattern, final boolean includeSubclasses) {
- T[] instances = getGenericContainer().findInstances(cls, pattern, includeSubclasses);
- return asList(instances);
- }
-
- /**
- * Returns all the instances of the specified type that have the given title. This method will also search
- * through the instances of any subclasses if the includeSubclasses flag is set. If there are no instances
- * the list will be empty. This method creates a new list object each time it is called so the caller is
- * free to use or modify the returned List, but the changes will not be reflected back to the repository.
- */
- protected <T> List<T> allMatches(final Class<T> cls, final String title, final boolean includeSubclasses) {
- T[] instances = getGenericContainer().findInstances(cls, title, includeSubclasses);
- return asList(instances);
- }
-
- private <T> List<T> asList(T[] instances) {
- List<T> list = Arrays.asList(instances);
- return list;
- }
-
- /**
- * Returns the first instance that matches the supplied filter, or null if none. This method will also
- * search though the instances of any subclasses if the includeSubclasses flag is set.
- */
- protected <T> T firstMatch(final Class<T> cls, final Filter filter, final boolean includeSubclasses) {
- T[] allInstances = getGenericContainer().allInstances(cls, includeSubclasses);
- for (int i = 0; i < allInstances.length; i++) {
- T instance = allInstances[i];
- if (filter.accept(instance)) {
- return instance;
- }
- }
- return null;
- }
-
- /**
- * Returns the first instance that matches the supplied filter, or null if none. This method will also
- * search though the instances of any subclasses if the includeSubclasses flag is set.
- */
- protected <T> T firstMatch(final Class<T> cls, final Object pattern, final boolean includeSubclasses) {
- return (T) getGenericContainer().firstInstance(cls, pattern, includeSubclasses);
- }
-
- /**
- * Returns the first instance that matches the supplied filter, or null if none. This method will also
- * search though the instances of any subclasses if the includeSubclasses flag is set.
- */
- protected <T> T firstMatch(final Class<T> cls, final String title, final boolean includeSubclasses) {
- return (T) getGenericContainer().firstInstance(cls, title, includeSubclasses);
- }
-
- /**
- * Returns a new instance of the specified class with a persisted state the same as the other object.
- * Therefore when the object is transient the new instance will not be persisted once it is created,
- * whereas if the object is persistent, then the new instance will be persisted once created.
- */
- protected <T> T newInstance(final Class<T> ofClass, final Object sameStateAs) {
- return getGenericContainer().newInstance(ofClass, sameStateAs);
- }
-
- /**
- * Returns a new instance of the specified class that will be persisted before returned.
- */
- protected <T> T newPersistentInstance(final Class<T> ofClass) {
- return getGenericContainer().newPersistentInstance(ofClass);
- }
-
- /**
- * Returns a new instance of the specified class that will not have been persisted.
- */
- protected <T> T newTransientInstance(final Class<T> ofClass) {
- return getGenericContainer().newTransientInstance(ofClass);
- }
-
- /**
- * Find the only instance of the specified type that has the specified title. If the includeSubclasses
- * flag is set then the search will also be include instances of all subclasses. If no instance is found
- * then null will be return, while if there is more that one instances a run-time exception will be
- * thrown.
- */
- protected <T> T uniqueMatch(final Class<T> cls, final Filter filter, final boolean includeSubclasses) {
- List<T> instances = allMatches(cls, filter, includeSubclasses);
- if (instances.size() == 1) {
- return instances.get(0);
- } else if (instances.size() == 0) {
- return null;
- } else {
- throw new RepositoryException("Found more that one instance matching filter " + filter);
- }
- }
-
- /**
- * Find the only instance of the specified type that has the specified title. If the includeSubclasses
- * flag is set then the search will also be include instances of all subclasses. If no instance is found
- * then null will be return, while if there is more that one instances a run-time exception will be
- * thrown.
- */
- protected <T> T uniqueMatch(final Class<T> cls, final String title, final boolean includeSubclasses) {
- return getGenericContainer().findInstance(cls, title, includeSubclasses);
- }
-
- /**
- * Find the only instance of the patterned object type that matches the set fields in the pattern object:
- * where any property that is set will be tested and properties that are not set will be ignored. If the
- * includeSubclasses flag is set then the search will also be include instances of all subclasses. If no
- * instance is found then null will be return, while if there is more that one instances a run-time
- * exception will be thrown.
- */
- protected <T> T uniqueMatch(final Class<T> cls, final T pattern, final boolean includeSubclasses) {
- return getGenericContainer().findInstance(cls, pattern, includeSubclasses);
- }
-}
-
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/DomainGenericObjectContainer.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/DomainGenericObjectContainer.java b/core/applib/src/main/src-archived/DomainGenericObjectContainer.java
deleted file mode 100644
index 34bafe0..0000000
--- a/core/applib/src/main/src-archived/DomainGenericObjectContainer.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.applib.generics;
-
-import org.apache.isis.applib.security.UserMemento;
-
-
-/**
- * Represents a container that the domain objects work within. It provides access to the persistence mechanism
- * and user interface.
- */
-public interface DomainGenericObjectContainer {
-
- //////////////////////// resolve, objectChanged //////////////////////////
-
- /**
- * Ensure that the specified object is completely loaded into memory.
- *
- * <p>
- * This forces the lazy loading mechanism to load the object if it is not already loaded.
- */
- void resolve(Object object);
-
- /**
- * Ensure that the specified object is completely loaded into memory, though only if the supplied field
- * reference is <tt>null</tt>.
- *
- * <p>
- * This forces the lazy loading mechanism to load the object if it is not already loaded.
- */
- void resolve(Object object, Object field);
-
- /**
- * Flags that the specified object's state has changed and its changes need to be saved.
- */
- void objectChanged(Object object);
-
-
- //////////////////////// new{Transient/Persistent}Instance //////////////////////////
-
- /**
- * Create a new instance of the specified class, but do not persist it.
- *
- * @see #newPersistentInstance(Class)
- */
- <T> T newTransientInstance(Class<T> ofClass);
-
- /**
- * Create a new instance of the specified class and persist it.
- *
- * @see #newTransientInstance(Class)
- */
- <T> T newPersistentInstance(Class<T> ofClass);
-
- /**
- * Create a new instance, of the specified class, in the same persistent state as the specified object.
- *
- * @see #newTransientInstance()
- * @see #newPersistentInstance()
- */
- <T> T newInstance(Class<T> ofClass, Object sameStateAs);
-
-
- //////////////////////// isPersistent, makePersistent, disposeInstance //////////////////////////
-
- /**
- * Determines if the specified object is persistent; that is is stored permanently outside of the virtual
- * machine.
- */
- boolean isPersistent(Object object);
-
- /**
- * Make the specified transient object persistent. Throws an exception if object is already persistent.
- */
- void makePersistent(Object transientObject);
-
- void disposeInstance(Object persistentObject);
-
-
-
- //////////////////////// info, warn, error //////////////////////////
-
- /**
- * Make the specified message available to the user. Note this will probably be displayed in transitory
- * fashion, so is only suitable for useful but optional information.
- *
- * @see #warnUser(String)
- * @see #raiseError(String)
- */
- void informUser(String message);
-
- /**
- * Warn the user about a situation with the specified message. The container should guarantee to display
- * this warning to the user.
- *
- * @see #raiseError(String)
- * @see #informUser(String)
- */
- void warnUser(String message);
-
- /**
- * Notify the user of an application error with the specified message. Note this will probably be
- * displayed in an alarming fashion, so is only suitable for errors
- *
- * @see #warnUser(String)
- * @see #informUser(String)
- */
- void raiseError(String message);
-
-
- //////////////////////// security //////////////////////////
-
- /**
- * Get the details about the current user.
- */
- UserMemento getUser();
-
-
-
- //////////// allInstances, findInstances, findInstance, firstInstance ///////////////////
-
- /**
- * Use of this method is discouraged; instead use a repository.
- */
- <T> T[] allInstances(Class<T> cls, boolean includeSubclasses);
-
- /**
- * Use of this method is discouraged; instead use a repository.
- */
- <T> T[] findInstances(Class<T> cls, String title, boolean includeSubclasses);
-
- /**
- * Use of this method is discouraged; instead use a repository.
- */
- <T> T[] findInstances(Class<T> cls, Object pattern, boolean includeSubclasses);
-
- /**
- * Use of this method is discouraged; instead use a repository.
- */
- <T> T findInstance(Class<T> cls, String title, boolean includeSubclasses);
-
- /**
- * Use of this method is discouraged; instead use a repository.
- */
- <T> T findInstance(Class<T> cls, Object pattern, boolean includeSubclasses);
-
- /**
- * Use of this method is discouraged; instead use a repository.
- */
- <T> T firstInstance(Class<T> cls, String title, boolean includeSubclasses);
-
- /**
- * Use of this method is discouraged; instead use a repository.
- */
- <T> T firstInstance(Class<T> cls, Object pattern, boolean includeSubclasses);
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/annotations/BusinessKey.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/annotations/BusinessKey.java b/core/applib/src/main/src-archived/annotations/BusinessKey.java
deleted file mode 100644
index 240ab91..0000000
--- a/core/applib/src/main/src-archived/annotations/BusinessKey.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-
-/**
- * Indicates that the attribute is an alternate key or a
- * part of an business key (sometimes called alternate key).
- *
- * <p>
- * Not yet supported.
- */
-@Inherited
-@Target( { ElementType.METHOD })
-@Retention(RetentionPolicy.RUNTIME)
-public @interface BusinessKey {
-
- String value() default "";
-}
-
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/annotations/Cached.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/annotations/Cached.java b/core/applib/src/main/src-archived/annotations/Cached.java
deleted file mode 100644
index 8564c99..0000000
--- a/core/applib/src/main/src-archived/annotations/Cached.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Indicates the instances for this class should be cached.
- *
- * <p>
- * Not yet supported.
- */
-@Inherited
-@Target({ElementType.TYPE})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Cached {
-}
-
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/annotations/Searchable.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/annotations/Searchable.java b/core/applib/src/main/src-archived/annotations/Searchable.java
deleted file mode 100644
index fef7376..0000000
--- a/core/applib/src/main/src-archived/annotations/Searchable.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-
-
-import org.apache.isis.applib.AbstractFactoryAndRepository;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-
-/**
- * Indicates that the attribute is an alternate key or a part of an business key (sometimes called alternate key).
- * Eg
- * @Searchable(repository=AbstractFactoryAndRepository.class, queryByExample=false)
- * <p>
- * Not yet implemented.
- */
-@Inherited
-@Target( { ElementType.TYPE })
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Searchable {
-
- Class repository() default AbstractFactoryAndRepository.class;
-
- boolean queryByExample() default true;
-}
-
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/interfaces/Aggregated.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/interfaces/Aggregated.java b/core/applib/src/main/src-archived/interfaces/Aggregated.java
deleted file mode 100644
index 736804f..0000000
--- a/core/applib/src/main/src-archived/interfaces/Aggregated.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.applib;
-
-/**
- * @deprecated - use {@link org.apache.isis.applib.annotation.Aggregated} annotation instead.
- */
-public interface Aggregated {
- Object getAggregate();
-}
-
-
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/interfaces/Cached.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/interfaces/Cached.java b/core/applib/src/main/src-archived/interfaces/Cached.java
deleted file mode 100644
index d8330ea..0000000
--- a/core/applib/src/main/src-archived/interfaces/Cached.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.applib;
-
-/**
- * Marker interface to indicate that a class's instances can be cached.
- *
- * <p>
- * @deprecated - replaced by {@link org.apache.isis.applib.annotation.Cached} annotation.
- */
-public interface Cached {}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/BusinessValueHolder.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/BusinessValueHolder.java b/core/applib/src/main/src-archived/old-valueholders/BusinessValueHolder.java
deleted file mode 100644
index 80fc588..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/BusinessValueHolder.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.BusinessObject;
-import org.apache.isis.application.Title;
-import org.apache.isis.application.TitledObject;
-import org.apache.isis.application.value.ValueParseException;
-
-
-public abstract class BusinessValueHolder implements TitledObject {
-
- protected BusinessValueHolder(final BusinessObject parent) {
- this.parent = parent;
- }
-
- /** The parent which owns this value */
- private BusinessObject parent;
-
- public BusinessObject getParent() {
- return parent;
- }
-
- /**
- * Invokes <code>objectChanged()</code> on parent, provided that parent has been specified (is not
- * <code>nothing</code>).
- */
- protected void parentChanged() {
- if (this.getParent() == null) {
- return;
- }
- this.getParent().objectChanged();
- }
-
- protected void ensureAtLeastPartResolved() {
- }
-
- /** By default all values are changeable by the user */
- public boolean userChangeable() {
- return true;
- }
-
- public abstract boolean isEmpty();
-
- public abstract boolean isSameAs(final BusinessValueHolder object);
-
- public String titleString() {
- return title().toString();
- }
-
- public abstract Title title();
-
- /**
- * Returns a string representation of this object.
- * <p>
- * The specification of this string representation is not fixed, but, at the time of writing, consists of
- * <i>title [short ObjectAdapterClassName] </i>
- * </p>
- *
- * @return string representation of object.
- */
- public String toString() {
- return titleString(); // + " [" + this.getClass().getName() + "]";
- }
-
- public Object getValue() {
- return this;
- }
-
- public abstract void parseUserEntry(final String text) throws ValueParseException;
-
- public abstract void restoreFromEncodedString(final String data);
-
- public abstract String asEncodedString();
-
- public abstract void copyObject(final BusinessValueHolder object);
-
- public abstract void clear();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/Case.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/Case.java b/core/applib/src/main/src-archived/old-valueholders/Case.java
deleted file mode 100644
index 4cdd9af..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/Case.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-public class Case {
- public static final Case INSENSITIVE = new Case("insensitive");
-
- public static final Case SENSITIVE = new Case("sensitive");
- private String name;
-
- private Case(final String name) {
- this.name = name;
- }
-
- public String toString() {
- return name;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/Color.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/Color.java b/core/applib/src/main/src-archived/old-valueholders/Color.java
deleted file mode 100644
index c07dba4..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/Color.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.BusinessObject;
-import org.apache.isis.application.Title;
-import org.apache.isis.application.value.ValueParseException;
-
-
-public class Color extends Magnitude {
- private int color;
- private boolean isNull;
-
- public Color() {
- this(null);
- }
-
- public Color(final int color) {
- this(null, color);
- }
-
- public Color(final BusinessObject parent) {
- super(parent);
- clear();
- }
-
- public Color(final BusinessObject parent, final int color) {
- super(parent);
- setValue(color);
- }
-
- public void clear() {
- setValuesInternal(0, true, true);
- }
-
- public void copyObject(final BusinessValueHolder object) {
- if (object == null) {
- this.clear();
- } else if (!(object instanceof Color)) {
- throw new IllegalArgumentException("Can only copy the value of a Color object");
- } else {
- setValue((Color) object);
- }
- }
-
- public int intValue() {
- this.ensureAtLeastPartResolved();
- return color;
- }
-
- public boolean isEmpty() {
- this.ensureAtLeastPartResolved();
- return isNull;
- }
-
- /**
- * returns true if the number of this object has the same value as the specified number
- */
- public boolean isEqualTo(final Magnitude number) {
- this.ensureAtLeastPartResolved();
- if (number instanceof Color) {
- if (isNull) {
- return number.isEmpty();
- }
- return ((Color) number).color == color;
- } else {
- throw new IllegalArgumentException("Parameter must be of type Color");
- }
- }
-
- /**
- * Returns true if this value is less than the specified value.
- */
- public boolean isLessThan(final Magnitude value) {
- this.ensureAtLeastPartResolved();
- if (value instanceof Color) {
- return !isNull && !value.isEmpty() && color < ((Color) value).color;
- } else {
- throw new IllegalArgumentException("Parameter must be of type Color");
- }
- }
-
- public void parseUserEntry(final String text) throws ValueParseException {
- if (text == null || text.trim().equals("")) {
- clear();
- } else {
- try {
- if (text.startsWith("0x")) {
- setValue(Integer.parseInt(text.substring(2), 16));
- } else if (text.startsWith("#")) {
- setValue(Integer.parseInt(text.substring(1), 16));
- } else {
- setValue(Integer.parseInt(text));
- }
- } catch (NumberFormatException e) {
- throw new ValueParseException("Invalid number", e);
- }
- }
- }
-
- public void reset() {
- setValuesInternal(0, false, true);
- }
-
- public void restoreFromEncodedString(final String data) {
- if (data == null || data.equals("NULL")) {
- setValuesInternal(0, true, false);
- } else {
- setValuesInternal(Integer.valueOf(data).intValue(), false, false);
- }
- }
-
- public String asEncodedString() {
- // note: isEmpty does this.ensureAtLeastPartResolved();
- if (isEmpty()) {
- return "NULL";
- } else {
- return String.valueOf(intValue());
- }
- }
-
- public void setValue(final Color value) {
- if (value.isEmpty()) {
- clear();
- } else {
- setValuesInternal(value.intValue(), value.isNull, true);
- }
- }
-
- public void setValue(final int color) {
- setValuesInternal(color, false, true);
- }
-
- private void setValuesInternal(final int color, final boolean isNull, final boolean notify) {
- if (notify) {
- ensureAtLeastPartResolved();
- }
- this.color = color;
- this.isNull = isNull;
- if (notify) {
- parentChanged();
- }
- }
-
- public Title title() {
- this.ensureAtLeastPartResolved();
- if (color == 0) {
- return new Title("Black");
- } else if (color == 0xffffff) {
- return new Title("White");
- } else {
- return new Title("0x" + Integer.toHexString(color));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/ColorTest.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/ColorTest.java b/core/applib/src/main/src-archived/old-valueholders/ColorTest.java
deleted file mode 100644
index fc7f6f8..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/ColorTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.easymock.MockControl;
-import org.apache.isis.application.BusinessObject;
-
-
-public class ColorTest extends ValueTestCase {
-
- public void testEncodedString() {
- MockControl control = MockControl.createControl(BusinessObject.class);
- BusinessObject bo = (BusinessObject) control.getMock();
- bo.objectChanged();
- control.replay(); // finished recording
-
- Color color = new Color(bo);
- assertEquals("enc", "NULL", color.asEncodedString());
-
- control.verify();
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/Date.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/Date.java b/core/applib/src/main/src-archived/old-valueholders/Date.java
deleted file mode 100644
index 84b9d3a..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/Date.java
+++ /dev/null
@@ -1,515 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.ApplicationException;
-import org.apache.isis.application.BusinessObject;
-import org.apache.isis.application.Clock;
-import org.apache.isis.application.Title;
-import org.apache.isis.application.value.ValueParseException;
-
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-
-
-/**
- * Value object representing a date, time, or datestamp value.
- * <p>
- * This object <i>does </i> support value listeners.
- * </p>
- */
-
-/*
- * other methods to implement comparision methods
- *
- * sameDateAs() day == day & mont == month & year == year
- *
- * withinNextDatePeriod(int days, int months, int years) withinDatePeriod(int days, int months, int years)
- * withinPreviousDatePeriod(int days, int months, int years)
- */
-public class Date extends Magnitude {
- private static Clock clock;
- private static final DateFormat ISO_LONG = new SimpleDateFormat("yyyy-MM-dd");
- private static final DateFormat ISO_SHORT = new SimpleDateFormat("yyyyMMdd");
- private static final DateFormat LONG_FORMAT = DateFormat.getDateInstance(DateFormat.LONG);
- private static final DateFormat MEDIUM_FORMAT = DateFormat.getDateInstance(DateFormat.MEDIUM);
- private static final long serialVersionUID = 1L;
- private static final DateFormat SHORT_FORMAT = DateFormat.getDateInstance(DateFormat.SHORT);
-
- public static void setClock(final Clock clock) {
- Date.clock = clock;
-
- ISO_LONG.setLenient(false);
- ISO_SHORT.setLenient(false);
- LONG_FORMAT.setLenient(false);
- MEDIUM_FORMAT.setLenient(false);
- SHORT_FORMAT.setLenient(false);
- }
-
- private java.util.Date date;
- private boolean isNull = true;
-
- /*
- * Create a Date object for storing a date. The date is set to today's date.
- */
- public Date() {
- this((BusinessObject) null);
- }
-
- /*
- * Create a Date object for storing a date with the date set to the specified date.
- */
- public Date(final Date date) {
- // this.date = date.date;
- // isNull = date.isNull;
- this(null, date);
- }
-
- /*
- * Create a Date object for storing a date with the time set to the specified day, month and year.
- */
- public Date(final int year, final int month, final int day) {
- this(null, year, month, day);
- // isNull = false; // moved to set(Calendar) - called by setDate()
- }
-
- /*
- * Create a Date object for storing a date. The date is set to today's date.
- */
- public Date(final BusinessObject parent) {
- super(parent);
- today();
- }
-
- /*
- * Create a Date object for storing a date with the date set to the specified date.
- */
- public Date(final BusinessObject parent, final Date date) {
- // this.date = date.date;
- // isNull = date.isNull;
- super(parent);
- setValue(date);
- }
-
- /*
- * Create a Date object for storing a date with the time set to the specified day, month and year.
- */
- public Date(final BusinessObject parent, final int year, final int month, final int day) {
- super(parent);
- setValue(year, month, day);
- // isNull = false; // moved to set(Calendar) - called by setDate()
- }
-
- /**
- * Add the specified days, years and months to this date value.
- */
- public void add(final int years, final int months, final int days) {
- Calendar cal = Calendar.getInstance();
-
- cal.setTime(date);
- cal.add(Calendar.DAY_OF_MONTH, days);
- cal.add(Calendar.MONTH, months);
- cal.add(Calendar.YEAR, years);
- set(cal);
- }
-
- public Calendar calendarValue() {
- this.ensureAtLeastPartResolved();
- if (isNull) {
- return null;
- }
-
- Calendar c = Calendar.getInstance();
- c.setTime(date);
-
- return c;
- }
-
- private void checkDate(final int year, final int month, final int day) {
- if ((month < 1) || (month > 12)) {
- throw new IllegalArgumentException("Month must be in the range 1 - 12 inclusive");
- }
-
- Calendar cal = Calendar.getInstance();
-
- cal.set(year, month - 1, 0);
-
- int lastDayOfMonth = cal.getMaximum(Calendar.DAY_OF_MONTH);
-
- if ((day < 1) || (day > lastDayOfMonth)) {
- throw new IllegalArgumentException("Day must be in the range 1 - " + lastDayOfMonth + " inclusive: " + day);
- }
- }
-
- public void clear() {
- setValuesInternal(date, true, true);
- }
-
- /**
- * clear all aspects of the time that are not used
- */
- private void clearDate(final Calendar cal) {
- cal.set(Calendar.HOUR, 0);
- cal.set(Calendar.HOUR_OF_DAY, 0);
- cal.set(Calendar.MINUTE, 0);
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.AM_PM, 0);
- cal.set(Calendar.MILLISECOND, 0);
- }
-
- public void copyObject(final BusinessValueHolder object) {
- if (!(object instanceof Date)) {
- throw new IllegalArgumentException("Can only copy the value of a Date object");
- }
- setValue((Date) object);
- }
-
- public java.util.Date dateValue() {
- this.ensureAtLeastPartResolved();
- return isNull ? null : date;
- }
-
- public boolean equals(final Object obj) {
- this.ensureAtLeastPartResolved();
- if (obj instanceof Date) {
- Date d = (Date) obj;
- return d.date.equals(date);
- }
- return super.equals(obj);
- }
-
- public int getDay() {
- this.ensureAtLeastPartResolved();
- Calendar c = Calendar.getInstance();
- c.setTime(date);
- return c.get(Calendar.DAY_OF_MONTH);
- }
-
- public int getMonth() {
- this.ensureAtLeastPartResolved();
- Calendar c = Calendar.getInstance();
- c.setTime(date);
- return c.get(Calendar.MONTH) + 1;
- }
-
- public int getYear() {
- this.ensureAtLeastPartResolved();
- Calendar c = Calendar.getInstance();
- c.setTime(date);
- return c.get(Calendar.YEAR);
- }
-
- /**
- * Return true if the date is blank
- */
- public boolean isEmpty() {
- this.ensureAtLeastPartResolved();
- return isNull;
- }
-
- /**
- * returns true if the date of this object has the same value as the specified date
- */
- public boolean isEqualTo(final Magnitude date) {
- this.ensureAtLeastPartResolved();
- if (date instanceof Date) {
- if (isNull) {
- return date.isEmpty();
- }
-
- return this.date.equals(((Date) date).date);
- } else {
- throw new IllegalArgumentException("Parameter must be of type Time");
- }
- }
-
- /**
- * returns true if the time of this object is earlier than the specified time
- */
- public boolean isLessThan(final Magnitude date) {
- this.ensureAtLeastPartResolved();
- if (date instanceof Date) {
- return !isNull && !date.isEmpty() && this.date.before(((Date) date).date);
- } else {
- throw new IllegalArgumentException("Parameter must be of type Time");
- }
- }
-
- /**
- * Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this date.
- */
- public long longValue() {
- this.ensureAtLeastPartResolved();
- return date.getTime();
- }
-
- public void parseUserEntry(final String dateStr) throws ValueParseException {
- String dateString = dateStr.trim();
-
- if (dateString.equals("")) {
- clear();
- } else {
- String str = dateString.toLowerCase();
- Calendar cal = Calendar.getInstance();
- cal.setTime(date);
- clearDate(cal);
-
- if (str.equals("today") || str.equals("now")) {
- today();
- return;
- } else if (str.startsWith("+")) {
- int days;
-
- // support for +1, +1d, +1w, +1m
- int unit = Calendar.DATE;
- int multiplier = 1;
- if (str.endsWith("w")) {
- multiplier = 7;
- str = str.substring(0, str.length() - 1);
- } else if (str.endsWith("m")) {
- unit = Calendar.MONTH;
- str = str.substring(0, str.length() - 1);
- }
-
- days = Integer.valueOf(str.substring(1)).intValue();
- cal.setTime(date);
- cal.add(unit, days * multiplier);
-
- } else if (str.startsWith("-")) {
- int days;
-
- // support for +1, +1d, +1w, +1m
- int unit = Calendar.DATE;
- int multiplier = 1;
- if (str.endsWith("w")) {
- multiplier = 7;
- str = str.substring(0, str.length() - 1);
- } else if (str.endsWith("m")) {
- unit = Calendar.MONTH;
- str = str.substring(0, str.length() - 1);
- }
-
- days = Integer.valueOf(str.substring(1)).intValue();
- cal.setTime(date);
- cal.add(unit, -days * multiplier);
-
- } else {
- DateFormat[] formats = new DateFormat[] { LONG_FORMAT, MEDIUM_FORMAT, SHORT_FORMAT, ISO_LONG, ISO_SHORT };
-
- for (int i = 0; i < formats.length; i++) {
- try {
- cal.setTime(formats[i].parse(dateString));
- break;
- } catch (ParseException e) {
- if ((i + 1) == formats.length) {
- throw new ValueParseException("Invalid date " + dateString, e);
- }
- }
- }
-
- }
-
- set(cal);
- }
- }
-
- public void readExternal(final java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException {
- isNull = in.readBoolean();
- date.setTime(in.readLong());
- }
-
- /**
- * Reset this date so it contains the current date.
- *
- *
- */
- public void reset() {
- today();
- }
-
- public void restoreFromEncodedString(final String data) {
- if (data.equals("NULL")) {
- setValuesInternal(date, true, false);
- } else {
- int year = Integer.valueOf(data.substring(0, 4)).intValue();
- int month = Integer.valueOf(data.substring(4, 6)).intValue();
- int day = Integer.valueOf(data.substring(6)).intValue();
- setValuesInternal(year, month, day, false);
- }
- }
-
- private boolean sameAs(final Date as, final int field) {
- this.ensureAtLeastPartResolved();
- Calendar c = Calendar.getInstance();
- c.setTime(date);
-
- Calendar c2 = Calendar.getInstance();
- c2.setTime(as.date);
-
- return c.get(field) == c2.get(field);
- }
-
- public boolean sameDayAs(final Date as) {
- return sameAs(as, Calendar.DAY_OF_YEAR);
- }
-
- public boolean sameMonthAs(final Date as) {
- return sameAs(as, Calendar.MONTH);
- }
-
- public boolean sameWeekAs(final Date as) {
- return sameAs(as, Calendar.WEEK_OF_YEAR);
- }
-
- public boolean sameYearAs(final Date as) {
- return sameAs(as, Calendar.YEAR);
- }
-
- public String asEncodedString() {
- // note: isEmpty does this.ensureAtLeastPartResolved();
- if (isEmpty()) {
- return "NULL";
- } else {
- Calendar cal = calendarValue();
- StringBuffer data = new StringBuffer(8);
- String year = String.valueOf(cal.get(Calendar.YEAR));
- data.append("0000".substring(0, 4 - year.length()));
- data.append(year);
-
- int month = cal.get(Calendar.MONTH) + 1;
- data.append((month <= 9) ? "0" : "");
- data.append(month);
-
- int day = cal.get(Calendar.DAY_OF_MONTH);
- data.append((day <= 9) ? "0" : "");
- data.append(day);
-
- return data.toString();
- }
- }
-
- private void set(final Calendar cal) {
- setValuesInternal(cal.getTime(), false, true);
- }
-
- private void setValuesInternal(final java.util.Date date, final boolean isNull, final boolean notify) {
- if (notify) {
- ensureAtLeastPartResolved();
- }
- this.date = date;
- this.isNull = isNull;
- if (notify) {
- parentChanged();
- }
- }
-
- private void setValuesInternal(final int year, final int month, final int day, final boolean notify) {
- checkDate(year, month, day);
-
- Calendar cal = Calendar.getInstance();
- clearDate(cal);
- cal.set(year, month - 1, day);
- setValuesInternal(cal.getTime(), false, notify);
- }
-
- public void setValue(final Date date) {
- if (date == null || date.isEmpty()) {
- clear();
- } else {
- setValuesInternal(new java.util.Date(date.longValue()), false, true);
- }
- }
-
- /**
- * Sets this object's date to be the same as the specified day, month and year.
- */
- public void setValue(final int year, final int month, final int day) {
- setValuesInternal(year, month, day, true);
- }
-
- public void setValue(final java.util.Date date) {
- if (date == null) {
- clear();
- } else {
- Calendar cal = Calendar.getInstance();
-
- cal.setTime(date);
- cal.set(Calendar.HOUR, 0);
- cal.set(Calendar.MINUTE, 0);
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.MILLISECOND, 0);
- set(cal);
- }
- }
-
- public Title title() {
- this.ensureAtLeastPartResolved();
- return new Title(isNull ? "" : MEDIUM_FORMAT.format(date));
- }
-
- /**
- * Sets this date value to todays date
- */
- public void today() {
- Calendar cal = Calendar.getInstance();
-
- if (clock == null) {
- throw new ApplicationException("Clock not set up");
- }
- long time = clock.getTime();
- java.util.Date d = new java.util.Date(time);
- cal.setTime(d);
-
- clearDate(cal);
- set(cal);
- }
-
- public void toStartOfMonth() {
- Calendar c = Calendar.getInstance();
- c.setTime(date);
-
- c.set(Calendar.MONTH, c.getMinimum(Calendar.MONTH));
- date = c.getTime();
- }
-
- public void toStartOfWeek() {
- Calendar c = Calendar.getInstance();
- c.setTime(date);
-
- c.set(Calendar.DAY_OF_WEEK_IN_MONTH, c.getMinimum(Calendar.DAY_OF_WEEK_IN_MONTH));
- date = c.getTime();
- }
-
- public void toStartOfYear() {
- Calendar c = Calendar.getInstance();
- c.setTime(date);
-
- c.set(Calendar.DAY_OF_YEAR, c.getMinimum(Calendar.DAY_OF_YEAR));
- date = c.getTime();
- }
-
- // sdm update
- public boolean isAfterToday(final Date d) {
- return isGreaterThan(new Date());
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/DatePeriod.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/DatePeriod.java b/core/applib/src/main/src-archived/old-valueholders/DatePeriod.java
deleted file mode 100644
index 4bd6220..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/DatePeriod.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.BusinessObject;
-import org.apache.isis.application.Title;
-import org.apache.isis.application.value.ValueParseException;
-
-
-public class DatePeriod extends BusinessValueHolder {
- private final Date end = new Date();
- private final Date start = new Date();
-
- public DatePeriod() {
- this((BusinessObject) null);
- }
-
- public DatePeriod(final DatePeriod period) {
- this(null, period);
- }
-
- public DatePeriod(final BusinessObject parent) {
- super(parent);
- clear();
- }
-
- public DatePeriod(final BusinessObject parent, final DatePeriod period) {
- super(parent);
- this.start.copyObject(period.start);
- this.end.copyObject(period.end);
- }
-
- public void clear() {
- clearInternal(true);
- }
-
- private void clearInternal(final boolean notify) {
- if (notify) {
- ensureAtLeastPartResolved();
- }
- start.clear();
- end.clear();
- if (notify) {
- parentChanged();
- }
- }
-
- public boolean contains(final Date d) {
- this.ensureAtLeastPartResolved();
- return d.isGreaterThanOrEqualTo(start) && d.isLessThanOrEqualTo(end);
- }
-
- public void copyObject(final BusinessValueHolder object) {
- if (!(object instanceof DatePeriod)) {
- throw new IllegalArgumentException();
- }
-
- DatePeriod dp = (DatePeriod) object;
-
- if (dp.isEmpty()) {
- clear();
- } else {
- setValue(dp);
- }
- }
-
- public boolean endsAfter(final DatePeriod arg) {
- if (getEndDate().isGreaterThan(arg.getEndDate())) {
- return true;
- } else {
- return false;
- }
- }
-
- public Date getEndDate() {
- this.ensureAtLeastPartResolved();
- return end;
- }
-
- public Date getStart() {
- this.ensureAtLeastPartResolved();
- return start;
- }
-
- public boolean isDatePeriod(final BusinessValueHolder object) {
- return object instanceof DatePeriod;
- }
-
- public boolean isEmpty() {
- return (getStart().isEmpty()) && (getEndDate().isEmpty());
- }
-
- public boolean isSameAs(final BusinessValueHolder object) {
- if (!(object instanceof DatePeriod)) {
- return false;
- } else {
- DatePeriod dp = (DatePeriod) object;
-
- return (getStart().isEqualTo(dp.getStart())) && (getEndDate().isEqualTo(dp.getEndDate()));
- }
- }
-
- public void leadDifference(final DatePeriod arg) {
- if (!this.overlaps(arg)) {
- throw new IllegalArgumentException("No overlap");
- } else {
- if (this.startsBefore(arg)) {
- getEndDate().setValue(arg.getStart());
- getEndDate().add(0, 0, -1);
- } else {
- getEndDate().setValue(getStart());
- getEndDate().add(0, 0, -1);
- getStart().setValue(arg.getStart());
- }
- }
- }
-
- public void overlap(final DatePeriod arg) {
- if (!this.overlaps(arg)) {
- throw new IllegalArgumentException("No overlap");
- } else {
- if (arg.getStart().isGreaterThan(getStart())) {
- getStart().setValue(arg.getStart());
- } else {
- getStart().setValue(getStart());
- }
-
- if (arg.getEndDate().isLessThan(getEndDate())) {
- getEndDate().setValue(arg.getEndDate());
- } else {
- getEndDate().setValue(getEndDate());
- }
- }
- }
-
- public boolean overlaps(final DatePeriod arg) {
- return (getEndDate().isGreaterThan(arg.getStart()) && start.isLessThan(arg.getEndDate()));
- }
-
- public void parseUserEntry(final String text) throws ValueParseException {
- if (text.trim().equals("")) {
- clear();
- } else {
- int dash = text.indexOf("~");
-
- if (dash == -1) {
- throw new ValueParseException("No tilde found");
- }
- Date sd = new Date();
- Date ed = new Date();
- sd.parseUserEntry(text.substring(0, dash).trim());
- ed.parseUserEntry(text.substring(dash + 1).trim());
-
- if (ed.isLessThan(sd)) {
- throw new ValueParseException("End date must be before start date");
- }
- setValue(sd, ed);
- }
- }
-
- public void reset() {
- ensureAtLeastPartResolved();
- getStart().reset();
- getEndDate().reset();
- parentChanged();
- }
-
- public void restoreFromEncodedString(final String data) {
- if (data == null || data.equals("NULL")) {
- clearInternal(false);
- } else {
- int split = data.indexOf('~');
- getStart().restoreFromEncodedString(data.substring(0, split));
- getEndDate().restoreFromEncodedString(data.substring(split + 1));
- }
- }
-
- public String asEncodedString() {
- if (getStart().isEmpty() || getEndDate().isEmpty()) {
- return "NULL";
- } else {
- return getStart().asEncodedString() + "~" + getEndDate().asEncodedString();
- }
- }
-
- public void setValue(final Date start, final Date end) {
- getStart().setValue(start);
- getEndDate().setValue(end);
- parentChanged();
- }
-
- public void setValue(final DatePeriod dp) {
- setValue(dp.getStart(), dp.getEndDate());
- }
-
- public boolean startsBefore(final DatePeriod arg) {
- if (getStart().isLessThan(arg.getStart())) {
- return true;
- } else {
- return false;
- }
- }
-
- public void tailDifference(final DatePeriod arg) {
- if (!this.overlaps(arg)) {
- throw new IllegalArgumentException("No overlap");
- } else {
- if (this.endsAfter(arg)) {
- getStart().setValue(arg.getEndDate());
- getStart().add(0, 0, 1);
- } else {
- getStart().setValue(getEndDate());
- getStart().add(0, 0, 1);
- getEndDate().setValue(arg.getEndDate());
- }
- }
- }
-
- public Title title() {
- Title t = new Title(getStart() == null ? "" : getStart().title().toString());
- t.append("~");
- t.append(getEndDate() == null ? "" : getEndDate().title().toString());
-
- return t;
- }
-
- /*
- * To be added:
- *
- * method to test that a magnitude falls within the range method to test if two ranges are contiguous
- * method to return the enclosing range for two ranges method to test if one range falls entirely within
- * another
- */
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/DatePeriodTest.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/DatePeriodTest.java b/core/applib/src/main/src-archived/old-valueholders/DatePeriodTest.java
deleted file mode 100644
index a576c32..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/DatePeriodTest.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.value.ValueParseException;
-
-import java.util.Locale;
-
-
-public class DatePeriodTest extends ValueTestCase {
- static {
- Locale.setDefault(Locale.UK);
- }
-
- private DatePeriod mayJul, junAug, junJul, dp1, dp2;
-
- protected void setUp() throws Exception {
- super.setUp();
-
- mayJul = new DatePeriod();
- mayJul.getStart().setValue(2003, 5, 1);
- mayJul.getEndDate().setValue(2003, 7, 31);
-
- junAug = new DatePeriod();
- junAug.getStart().setValue(2003, 6, 1);
- junAug.getEndDate().setValue(2003, 8, 31);
-
- junJul = new DatePeriod();
- junJul.getStart().setValue(2003, 6, 1);
- junJul.getEndDate().setValue(2003, 7, 31);
-
- dp1 = new DatePeriod();
- dp2 = new DatePeriod();
- }
-
- public void testLocale() {
- assertEquals(Locale.UK, Locale.getDefault());
-
- }
-
- protected void tearDown() throws Exception {
- mayJul = null;
- junAug = null;
- junJul = null;
- }
-
- public void testClear() {
- mayJul.clear();
- assertTrue(mayJul.title().toString().equals("~"));
- assertTrue(mayJul.isEmpty());
- }
-
- public void testOverlaps() throws Exception {
-
- assertTrue(mayJul.startsBefore(junAug));
- assertFalse(junAug.startsBefore(mayJul));
- assertTrue(junAug.endsAfter(mayJul));
- assertFalse(mayJul.endsAfter(junAug));
-
- assertTrue(mayJul.overlaps(junAug));
-
- DatePeriod overlap = new DatePeriod(mayJul);
- overlap.overlap(junAug);
- assertTrue(junJul.isSameAs(overlap));
-
- overlap = new DatePeriod(junAug);
- overlap.overlap(mayJul);
- assertTrue(junJul.isSameAs(overlap));
-
- DatePeriod lead = new DatePeriod(junAug);
- lead.leadDifference(mayJul);
- // assertEquals("01-May-2003 ~ 31-May-2003", lead.title().toString());
-
- DatePeriod tail = new DatePeriod(junAug);
- tail.tailDifference(mayJul);
- assertEquals("01-Aug-2003 ~ 31-Aug-2003", tail.title().toString());
- }
-
- public void testParse() throws Exception {
- dp1.parseUserEntry("14-Apr-2003 ~ 16-Nov-2004");
- assertEquals("14-Apr-2003 ~ 16-Nov-2004", dp1.title().toString());
- dp1.parseUserEntry("15-Jan-2002 ~ 6-May-2005");
- assertEquals("15-Jan-2002 ~ 06-May-2005", dp1.title().toString());
- dp1.parseUserEntry("5-jan-2002~06-may-2005");
- assertEquals("05-Jan-2002 ~ 06-May-2005", dp1.title().toString());
- try {
- dp1.parseUserEntry("hgjuiy");
- fail();
- } catch (ValueParseException e) {
- assertTrue(e.getMessage().equals("No tilde found"));
- }
- try {
- dp1.parseUserEntry("05-Jan-2002 - 06-May-2005");
- fail();
- } catch (ValueParseException e) {
- assertTrue(e.getMessage().equals("No tilde found"));
- }
- try {
- dp1.parseUserEntry("rtyu~ghjk");
- fail();
- } catch (ValueParseException e) {
- assertTrue(e.getMessage().equals("Invalid date rtyu"));
- }
- try {
- dp1.parseUserEntry("14-Apr-2003 ~ 16-Nov-2002");
- fail();
- } catch (ValueParseException expected) {}
-
- dp1.parseUserEntry("14-Apr-2003~");
- assertTrue(dp1.title().toString().equals("14-Apr-2003 ~"));
- dp1.parseUserEntry("~16-Nov-2004");
- assertTrue(dp1.title().toString().equals("~ 16-Nov-2004"));
-
- }
-
- public void testSaveAndRestore() throws Exception {
- dp1.parseUserEntry("04-May-2003 ~ 16-May-2004");
- String s = dp1.asEncodedString();
- assertEquals("20030504~20040516", s);
- dp2.restoreFromEncodedString(s);
- assertEquals("04-May-2003 ~ 16-May-2004", dp2.title().toString());
- assertTrue(dp1.isSameAs(dp2));
- }
-
-}
[3/4] ISIS-518,
ISIS-519: deprecating applib's Filter and deleting archived code.
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/DateTest.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/DateTest.java b/core/applib/src/main/src-archived/old-valueholders/DateTest.java
deleted file mode 100644
index c34cdcf..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/DateTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.system.TestClock;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class DateTest extends ValueTestCase {
-
- private Date actual;
-
- protected void setUp() throws Exception {
- Logger.getRootLogger().setLevel(Level.OFF);
-
- Date.setClock(new TestClock());
- actual = new Date(2000, 2, 1);
- }
-
- public void testGetDay() {
- assertEquals(1, actual.getDay());
- }
-
- public void testGetMonth() {
- assertEquals(2, actual.getMonth());
- }
-
- public void testGetYear() {
- assertEquals(2000, actual.getYear());
- }
-
- public void testNew() {
- Date expected = new Date(2003, 8, 17);
- Date actual = new Date();
- assertEquals(expected, actual);
- }
-
- public void testReset() {
- Date expected = new Date(2003, 8, 17);
- actual.reset();
- assertEquals(expected, actual);
- }
-
- public void testSaveRestore() throws Exception {
- Date date1 = new Date();
- date1.parseUserEntry("2003-1-4");
- assertFalse(date1.isEmpty());
-
- Date date2 = new Date();
- date2.restoreFromEncodedString(date1.asEncodedString());
- assertEquals(date1.dateValue(), date2.dateValue());
- assertFalse(date2.isEmpty());
- }
-
- public void testSaveRestorOfNull() throws Exception {
- Date date1 = new Date();
- date1.clear();
- assertTrue("Date isEmpty", date1.isEmpty());
-
- Date date2 = new Date();
- date2.restoreFromEncodedString(date1.asEncodedString());
- assertEquals(date1.dateValue(), date2.dateValue());
- assertTrue(date2.isEmpty());
- }
-
- public void testToday() {
- Date expected = new Date(2003, 8, 17);
- actual.today();
- assertEquals(expected, actual);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/DateTime.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/DateTime.java b/core/applib/src/main/src-archived/old-valueholders/DateTime.java
deleted file mode 100644
index d251aef..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/DateTime.java
+++ /dev/null
@@ -1,461 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.ApplicationException;
-import org.apache.isis.application.BusinessObject;
-import org.apache.isis.application.Clock;
-import org.apache.isis.application.Title;
-import org.apache.isis.application.value.ValueParseException;
-
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-
-
-/**
- * Value object representing a date and time value.
- * <p>
- * NOTE: this class currently does not support about listeners
- * </p>
- */
-public class DateTime extends Magnitude {
- private static final long serialVersionUID = 1L;
- private static final DateFormat SHORT_FORMAT = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
- private static final DateFormat MEDIUM_FORMAT = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT);
- private static final DateFormat LONG_FORMAT = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG);
- private static final DateFormat ISO_LONG = new SimpleDateFormat("yyyy-MM-dd HH:mm");
- private static final DateFormat ISO_SHORT = new SimpleDateFormat("yyyyMMdd'T'HHmm");
-
- private transient DateFormat format = MEDIUM_FORMAT;
- private boolean isNull = true;
- private java.util.Date date;
- private static Clock clock;
-
- public static void setClock(final Clock clock) {
- DateTime.clock = clock;
-
- ISO_LONG.setLenient(false);
- ISO_SHORT.setLenient(false);
- LONG_FORMAT.setLenient(false);
- MEDIUM_FORMAT.setLenient(false);
- SHORT_FORMAT.setLenient(false);
- }
-
- /**
- * Create a Time object for storing a timeStamp set to the current time.
- */
- public DateTime() {
- this((BusinessObject) null);
- }
-
- /**
- * Create a Time object for storing a timeStamp set to the specified hours and minutes.
- *
- * @deprecated replaced by TimeStamp(int year, int month, int day, int hour, int minute, int second)
- */
- public DateTime(final int year, final int month, final int day, final int hour, final int minute) {
- this(null, year, month, day, hour, minute, 0);
- }
-
- /**
- * Create a Time object for storing a timeStamp set to the specified hours and minutes.
- */
- public DateTime(final int year, final int month, final int day, final int hour, final int minute, final int second) {
- this(null, year, month, day, hour, minute, second);
- }
-
- /**
- * Create a Time object for storing a timeStamp set to the specified time.
- */
- public DateTime(final DateTime timeStamp) {
- this(null, timeStamp);
- }
-
- /**
- * Create a Time object for storing a timeStamp set to the current time.
- */
- public DateTime(final BusinessObject parent) {
- super(parent);
- if (clock == null) {
- throw new ApplicationException("Clock not set up");
- }
- setValue(new java.util.Date(clock.getTime()));
- isNull = false;
- }
-
- /**
- * Create a Time object for storing a timeStamp set to the specified hours and minutes.
- */
- public DateTime(final BusinessObject parent, final int year, final int month, final int day, final int hour, final int minute, final int second) {
- super(parent);
- setValue(year, month, day, hour, minute, second);
- isNull = false;
- }
-
- /**
- * Create a Time object for storing a timeStamp set to the specified time.
- */
- public DateTime(final BusinessObject parent, final DateTime timeStamp) {
- super(parent);
- date = timeStamp.date;
- isNull = timeStamp.isNull;
- }
-
- /**
- * Add the specified days, years and months to this date value.
- */
- public void add(final int hours, final int minutes, final int seconds) {
- Calendar cal = Calendar.getInstance();
-
- cal.setTime(date);
- cal.add(Calendar.SECOND, seconds);
- cal.add(Calendar.MINUTE, minutes);
- cal.add(Calendar.HOUR_OF_DAY, hours);
- set(cal);
- }
-
- private void checkTime(final int year, final int month, final int day, final int hour, final int minute, final int second) {
- if ((month < 1) || (month > 12)) {
- throw new IllegalArgumentException("Month must be in the range 1 - 12 inclusive " + month);
- }
-
- Calendar cal = Calendar.getInstance();
-
- cal.set(year, month - 1, 0);
-
- int lastDayOfMonth = cal.getMaximum(Calendar.DAY_OF_MONTH);
-
- if ((day < 1) || (day > lastDayOfMonth)) {
- throw new IllegalArgumentException("Day must be in the range 1 - " + lastDayOfMonth + " inclusive " + day);
- }
-
- if ((hour < 0) || (hour > 23)) {
- throw new IllegalArgumentException("Hour must be in the range 0 - 23 inclusive " + hour);
- }
-
- if ((minute < 0) || (minute > 59)) {
- throw new IllegalArgumentException("Minute must be in the range 0 - 59 inclusive " + minute);
- }
-
- if ((second < 0) || (second > 59)) {
- throw new IllegalArgumentException("Second must be in the range 0 - 59 inclusive " + second);
- }
- }
-
- public void clear() {
- setValuesInternal(date, true, true);
- }
-
- public void copyObject(final BusinessValueHolder object) {
- if (object == null) {
- this.clear();
- } else if (!(object instanceof DateTime)) {
- throw new IllegalArgumentException("Can only copy the value of a TimeStamp object");
- } else {
- setValue((DateTime) object);
- }
- }
-
- /**
- * Returns a Calendar object with the irrelevant field (determined by this objects type) set to zero.
- */
- private Calendar createCalendar() {
- Calendar cal = Calendar.getInstance();
-
- // clear all aspects of the time that are not used
- cal.set(Calendar.MILLISECOND, 0);
-
- return cal;
- }
-
- public java.util.Date dateValue() {
- this.ensureAtLeastPartResolved();
- return isNull ? null : date;
- }
-
- public boolean equals(final Object obj) {
- this.ensureAtLeastPartResolved();
- if (obj instanceof DateTime) {
- DateTime d = (DateTime) obj;
- return d.date.equals(date);
- }
- return super.equals(obj);
- }
-
- /**
- * Return true if the time stamp is blank
- */
- public boolean isEmpty() {
- this.ensureAtLeastPartResolved();
- return isNull;
- }
-
- /**
- * returns true if the time stamp of this object has the same value as the specified time
- */
- public boolean isEqualTo(final Magnitude timeStamp) {
- this.ensureAtLeastPartResolved();
- if (timeStamp instanceof DateTime) {
- if (isNull) {
- return timeStamp.isEmpty();
- }
-
- return this.date.equals(((DateTime) timeStamp).date);
- } else {
- throw new IllegalArgumentException("Parameter must be of type Time");
- }
- }
-
- /**
- * returns true if the timeStamp of this object is earlier than the specified timeStamp
- */
- public boolean isLessThan(final Magnitude timeStamp) {
- this.ensureAtLeastPartResolved();
- if (timeStamp instanceof DateTime) {
- return !isNull && !timeStamp.isEmpty() && date.before(((DateTime) timeStamp).date);
- } else {
- throw new IllegalArgumentException("Parameter must be of type Time");
- }
- }
-
- public int getDay() {
- this.ensureAtLeastPartResolved();
- Calendar c = Calendar.getInstance();
- c.setTime(date);
- return c.get(Calendar.DAY_OF_MONTH);
- }
-
- public int getMonth() {
- this.ensureAtLeastPartResolved();
- Calendar c = Calendar.getInstance();
- c.setTime(date);
- return c.get(Calendar.MONTH) + 1;
- }
-
- public int getYear() {
- this.ensureAtLeastPartResolved();
- Calendar c = Calendar.getInstance();
- c.setTime(date);
- return c.get(Calendar.YEAR);
- }
-
- public int getHour() {
- this.ensureAtLeastPartResolved();
- Calendar c = Calendar.getInstance();
- c.setTime(date);
- return c.get(Calendar.HOUR);
- }
-
- public int getMinute() {
- this.ensureAtLeastPartResolved();
- Calendar c = Calendar.getInstance();
- c.setTime(date);
- return c.get(Calendar.MINUTE);
- }
-
- public long longValue() {
- this.ensureAtLeastPartResolved();
- return date.getTime();
- }
-
- public void parseUserEntry(final String entry) throws ValueParseException {
- if (entry.trim().equals("")) {
- clear();
- } else {
- String text = entry.trim();
-
- String str = text.toLowerCase();
- Calendar cal = createCalendar();
-
- if (str.equals("today") || str.equals("now")) {} else if (str.startsWith("+")) {
- int hours;
-
- hours = Integer.valueOf(str.substring(1)).intValue();
- cal.setTime(date);
- cal.add(Calendar.HOUR, hours);
- } else if (str.startsWith("-")) {
- int hours;
-
- hours = Integer.valueOf(str.substring(1)).intValue();
- cal.setTime(date);
- cal.add(Calendar.HOUR, -hours);
- } else {
- DateFormat[] formats = new DateFormat[] { LONG_FORMAT, MEDIUM_FORMAT, SHORT_FORMAT, ISO_LONG, ISO_SHORT };
-
- for (int i = 0; i < formats.length; i++) {
- try {
- cal.setTime(formats[i].parse(text));
-
- break;
- } catch (ParseException e) {
- if ((i + 1) == formats.length) {
- throw new ValueParseException("Invalid timeStamp " + text, e);
- }
- }
- }
- }
-
- set(cal);
- }
- }
-
- /**
- * Reset this time so it contains the current time.
- *
- */
- public void reset() {
- setValuesInternal(new Date(clock.getTime()), false, true);
- }
-
- private void set(final Calendar cal) {
- setValuesInternal(cal.getTime(), false, true);
- }
-
- private void setValuesInternal(final Date date, final boolean isNull, final boolean notify) {
- if (notify) {
- ensureAtLeastPartResolved();
- }
- this.date = date;
- this.isNull = isNull;
- if (notify) {
- parentChanged();
- }
- }
-
- private void setValuesInternal(
- final int year, final int month, final int day, final int hour, final int minute, final int second, final boolean notify) {
- checkTime(year, month, day, hour, minute, second);
-
- Calendar cal = createCalendar();
-
- cal.set(Calendar.DAY_OF_MONTH, day);
- cal.set(Calendar.MONTH, month - 1);
- cal.set(Calendar.YEAR, year);
- cal.set(Calendar.HOUR_OF_DAY, hour);
- cal.set(Calendar.MINUTE, minute);
- cal.set(Calendar.SECOND, second);
- cal.set(Calendar.MILLISECOND, 0);
- setValuesInternal(cal.getTime(), false, notify);
- }
-
- public void setValue(final java.util.Date date) {
- if (date == null) {
- setValuesInternal(date, true, true);
- } else {
- Calendar cal = Calendar.getInstance();
- cal.setTime(date);
- cal.set(Calendar.MILLISECOND, 0);
- set(cal);
- }
- }
-
- public void setValue(final long time) {
- setValuesInternal(new Date(time), false, true);
- }
-
- public void setValue(final DateTime timeStamp) {
- if (timeStamp == null) {
- setValuesInternal(date, true, true);
- } else {
- setValuesInternal(new Date(timeStamp.date.getTime()), false, true);
- }
- }
-
- /*
- * Sets this object's timeStamp to be the same as the specified hour, minute and second.
- */
- public void setValue(final int year, final int month, final int day, final int hour, final int minute, final int second) {
- setValuesInternal(year, month, day, hour, minute, second, false);
- }
-
- public Title title() {
- this.ensureAtLeastPartResolved();
- return new Title(isNull ? "" : format.format(date));
- }
-
- public Calendar calendarValue() {
- this.ensureAtLeastPartResolved();
- if (isNull) {
- return null;
- }
-
- Calendar c = Calendar.getInstance();
- c.setTime(date);
-
- return c;
- }
-
- public void restoreFromEncodedString(final String data) {
- if (data == null || data.equals("NULL")) {
- this.setValuesInternal(date, true, false);
- } else {
- int year = Integer.valueOf(data.substring(0, 4)).intValue();
- int month = Integer.valueOf(data.substring(4, 6)).intValue();
- int day = Integer.valueOf(data.substring(6, 8)).intValue();
- int hour = Integer.valueOf(data.substring(8, 10)).intValue();
- int minute = Integer.valueOf(data.substring(10, 12)).intValue();
- int second = Integer.valueOf(data.substring(12, 14)).intValue();
- setValuesInternal(year, month, day, hour, minute, second, false);
- }
- }
-
- public String asEncodedString() {
- if (isEmpty()) {
- return "NULL";
- } else {
- Calendar cal = calendarValue();
- StringBuffer data = new StringBuffer(8);
- String year = String.valueOf(cal.get(Calendar.YEAR));
- data.append("0000".substring(0, 4 - year.length()));
- data.append(year);
-
- int month = cal.get(Calendar.MONTH) + 1;
- data.append((month <= 9) ? "0" : "");
- data.append(month);
-
- int day = cal.get(Calendar.DAY_OF_MONTH);
- data.append((day <= 9) ? "0" : "");
- data.append(day);
-
- int hour = cal.get(Calendar.HOUR_OF_DAY);
- data.append((hour <= 9) ? "0" : "");
- data.append(hour);
-
- int minute = cal.get(Calendar.MINUTE);
- data.append((minute <= 9) ? "0" : "");
- data.append(minute);
-
- int second = cal.get(Calendar.SECOND);
- data.append((second <= 9) ? "0" : "");
- data.append(second);
-
- return data.toString();
- }
- }
-
- public String toString() {
- // title() ensures this is resolved
- return title() + " " + longValue() + " [DateTime]";
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/DateTimeTest.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/DateTimeTest.java b/core/applib/src/main/src-archived/old-valueholders/DateTimeTest.java
deleted file mode 100644
index 97b2fca..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/DateTimeTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-public class DateTimeTest extends ValueTestCase {
- private DateTime actual;
-
- protected void setUp() throws Exception {
- super.setUp();
- actual = new DateTime(2000, 2, 1, 10, 59, 30);
- }
-
- public void testGetDay() {
- assertEquals(1, actual.getDay());
- }
-
- public void testGetMonth() {
- assertEquals(2, actual.getMonth());
- }
-
- public void testGetYear() {
- assertEquals(2000, actual.getYear());
- }
-
- public void testGetMinute() {
- assertEquals(59, actual.getMinute());
- }
-
- public void testGetHour() {
- assertEquals(10, actual.getHour());
- }
-
- public void testSaveRestore() throws Exception {
- DateTime timeStamp1 = new DateTime();
- timeStamp1.parseUserEntry("2003-1-4 10:45");
- assertFalse(timeStamp1.isEmpty());
-
- DateTime timeStamp2 = new DateTime();
- timeStamp2.restoreFromEncodedString(timeStamp1.asEncodedString());
- assertEquals(timeStamp1.longValue(), timeStamp2.longValue());
- assertFalse(timeStamp2.isEmpty());
- }
-
- public void testSaveRestorOfNull() throws Exception {
- DateTime timeStamp1 = new DateTime();
- timeStamp1.clear();
- assertTrue("DateTime isEmpty", timeStamp1.isEmpty());
-
- DateTime timeStamp2 = new DateTime();
- timeStamp2.restoreFromEncodedString(timeStamp1.asEncodedString());
- // assertEquals(timeStamp1.longValue(), timeStamp2.longValue());
- assertTrue(timeStamp2.isEmpty());
- }
-
- public void testNew() {
- DateTime expected = new DateTime(2003, 8, 17, 21, 30, 25);
- DateTime actual = new DateTime();
-
-// FIX assertEquals(expected, actual);
- }
-
- public void testNow() {
- DateTime expected = new DateTime(2003, 8, 17, 21, 30, 25);
- DateTime actual = new DateTime();
- actual.reset();
- // FIX assertEquals(expected, actual);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/FloatingPointNumber.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/FloatingPointNumber.java b/core/applib/src/main/src-archived/old-valueholders/FloatingPointNumber.java
deleted file mode 100644
index e7a06e1..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/FloatingPointNumber.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.BusinessObject;
-import org.apache.isis.application.Title;
-import org.apache.isis.application.value.ValueParseException;
-
-import java.text.NumberFormat;
-import java.text.ParseException;
-
-
-public class FloatingPointNumber extends Magnitude {
- private static NumberFormat FORMAT = NumberFormat.getNumberInstance();
- private static final long serialVersionUID = 1L;
- private boolean isNull;
- private double value;
-
- public FloatingPointNumber() {
- this(null, 0.0);
- }
-
- public FloatingPointNumber(final double value) {
- this(null, value);
- }
-
- public FloatingPointNumber(final FloatingPointNumber value) {
- this(null, value);
- }
-
- public FloatingPointNumber(final BusinessObject parent) {
- this(parent, 0.0);
- }
-
- public FloatingPointNumber(final BusinessObject parent, final double value) {
- super(parent);
- this.value = value;
- isNull = false;
- }
-
- public FloatingPointNumber(final BusinessObject parent, final FloatingPointNumber value) {
- super(parent);
- this.isNull = value.isNull;
- this.value = value.value;
- }
-
- public void add(final double value) {
- this.setValue(this.doubleValue() + value);
- }
-
- public void add(final FloatingPointNumber number) {
- this.setValue(this.doubleValue() + number.doubleValue());
- }
-
- public void clear() {
- setValuesInternal(0, true, true);
- }
-
- /**
- * Copies the specified object's contained data to this instance. param object the object to copy the data
- * from
- */
- public void copyObject(final BusinessValueHolder object) {
- if (object == null) {
- this.clear();
- } else if (!(object instanceof FloatingPointNumber)) {
- throw new IllegalArgumentException("Can only copy the value of a FloatingPointNumber object");
- } else {
- setValue((FloatingPointNumber) object);
- }
- }
-
- public void divide(final double value) {
- this.setValue(this.doubleValue() / value);
- }
-
- public void divide(final FloatingPointNumber number) {
- this.setValue(this.doubleValue() / number.value);
- }
-
- /**
- * Returns this value as an double.
- */
- public double doubleValue() {
- this.ensureAtLeastPartResolved();
- return value;
- }
-
- public boolean equals(final Object obj) {
- this.ensureAtLeastPartResolved();
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof FloatingPointNumber)) {
- return false;
- }
- FloatingPointNumber object = (FloatingPointNumber) obj;
- if (object.isEmpty() && isEmpty()) {
- return true;
- }
- return object.value == value;
- }
-
- /**
- * Returns this value as an float.
- */
- public float floatValue() {
- this.ensureAtLeastPartResolved();
- return (float) value;
- }
-
- public String getObjectHelpText() {
- return "A floating point number object.";
- }
-
- /**
- * Returns this value as an int.
- */
- public int intValue() {
- this.ensureAtLeastPartResolved();
- return (int) value;
- }
-
- public boolean isEmpty() {
- this.ensureAtLeastPartResolved();
- return isNull;
- }
-
- public boolean isEqualTo(final Magnitude magnitude) {
- this.ensureAtLeastPartResolved();
- if (magnitude instanceof FloatingPointNumber) {
- if (isNull) {
- return magnitude.isEmpty();
- }
- return ((FloatingPointNumber) magnitude).value == value;
- } else {
- throw new IllegalArgumentException("Parameter must be of type FloatingPointNumber");
- }
- }
-
- public boolean isLessThan(final Magnitude magnitude) {
- this.ensureAtLeastPartResolved();
- if (magnitude instanceof FloatingPointNumber) {
- return !isEmpty() && !magnitude.isEmpty() && value < ((FloatingPointNumber) magnitude).value;
- } else {
- throw new IllegalArgumentException("Parameter must be of type FloatingPointNumber");
- }
- }
-
- /**
- * Returns this value as an long.
- */
- public long longValue() {
- this.ensureAtLeastPartResolved();
- return (long) value;
- }
-
- public void multiply(final double value) {
- this.setValue(this.doubleValue() * value);
- }
-
- public void multiply(final FloatingPointNumber number) {
- this.setValue(this.doubleValue() * number.value);
- }
-
- public void parseUserEntry(final String text) throws ValueParseException {
- if (text.trim().equals("")) {
- clear();
- } else {
- try {
- setValue(FORMAT.parse(text).doubleValue());
- } catch (ParseException e) {
- throw new ValueParseException("Invalid number", e);
- }
- }
- }
-
- /**
- * Reset this floating point number so it contains 0.0.
- *
- *
- */
- public void reset() {
- setValuesInternal(0.0, false, true);
- isNull = false;
- }
-
- public void restoreFromEncodedString(final String data) {
- if (data == null || data.equals("NULL")) {
- setValuesInternal(0.0, true, false);
- } else {
- setValuesInternal(Double.valueOf(data).doubleValue(), false, false);
- }
- }
-
- public String asEncodedString() {
- this.ensureAtLeastPartResolved();
- return isNull ? "NULL" : String.valueOf(doubleValue());
- }
-
- public void setValue(final double value) {
- setValuesInternal(value, false, true);
- }
-
- public void setValue(final FloatingPointNumber value) {
- setValuesInternal(value.value, value.isNull, true);
- }
-
- private void setValuesInternal(final double value, final boolean isNull, final boolean notify) {
- if (notify) {
- ensureAtLeastPartResolved();
- }
- this.value = value;
- this.isNull = isNull;
- if (notify) {
- parentChanged();
- }
- }
-
- /**
- * Returns this value as an short.
- */
- public short shortValue() {
- this.ensureAtLeastPartResolved();
- return (short) value;
- }
-
- public void subtract(final double value) {
- add(-value);
- }
-
- public void subtract(final FloatingPointNumber number) {
- add(-number.value);
- }
-
- public Title title() {
- return new Title(isEmpty() ? "" : FORMAT.format(value));
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/Label.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/Label.java b/core/applib/src/main/src-archived/old-valueholders/Label.java
deleted file mode 100644
index 7cdb1aa..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/Label.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.BusinessObject;
-
-
-/**
- * A read-only text string. This class does support value listeners.
- */
-public class Label extends TextString {
- private static final long serialVersionUID = 1L;
-
- public Label() {
- super();
- }
-
- public Label(final String text) {
- super(text);
- }
-
- public Label(final BusinessObject parent) {
- super(parent);
- }
-
- public Label(final BusinessObject parent, final String text) {
- super(parent, text);
- }
-
- public boolean userChangeable() {
- return false;
- }
-
- public String getObjectHelpText() {
- return "A Label object.";
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/Logical.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/Logical.java b/core/applib/src/main/src-archived/old-valueholders/Logical.java
deleted file mode 100644
index 676dc06..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/Logical.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.BusinessObject;
-import org.apache.isis.application.Title;
-import org.apache.isis.application.value.ValueParseException;
-
-
-/**
- * Value object representing a true or false value.
- * <p>
- * NOTE: this class currently does not support about listeners.
- * </p>
- */
-public class Logical extends BusinessValueHolder {
- public final static String FALSE = "false";
- private static final long serialVersionUID = 1L;
- public final static String TRUE = "true";
- private boolean flag;
- private boolean isNull;
-
- /**
- * Creates a Logical value set to false.
- */
- public Logical() {
- this(null, false);
- }
-
- /**
- * Creates a Logical value set to the specified value.
- */
- public Logical(final boolean flag) {
- this(null, flag);
- }
-
- /**
- * Creates a Logical value set to false.
- */
- public Logical(final BusinessObject parent) {
- this(parent, false);
- }
-
- /**
- * Creates a Logical value set to the specified value.
- */
- public Logical(final BusinessObject parent, final boolean flag) {
- super(parent);
- this.flag = flag;
- isNull = false;
- }
-
- public boolean booleanValue() {
- this.ensureAtLeastPartResolved();
- return flag;
- }
-
- public void clear() {
- setValuesInternal(false, true, true);
- }
-
- public void copyObject(final BusinessValueHolder object) {
- if (object == null) {
- this.clear();
- } else if (!(object instanceof Logical)) {
- throw new IllegalArgumentException("Can only copy the value of a Logical object");
- } else {
- setValue((Logical) object);
- }
- }
-
- public boolean equals(final Object obj) {
- this.ensureAtLeastPartResolved();
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof Logical)) {
- return false;
- }
- Logical object = (Logical) obj;
- if (object.isEmpty() && isEmpty()) {
- return true;
- }
- return object.flag == flag;
- }
-
- public String getObjectHelpText() {
- return "A Logical object containing either True or False.";
- }
-
- public boolean isEmpty() {
- this.ensureAtLeastPartResolved();
- return isNull;
- }
-
- /**
- * Compares the flags if specified object is a <code>Logical</code> object else returns false.
- *
- * @see BusinessValueHolder#isSameAs(BusinessValueHolder)
- */
- public boolean isSameAs(final BusinessValueHolder object) {
- this.ensureAtLeastPartResolved();
- if (object instanceof Logical) {
- return ((Logical) object).flag == flag;
- } else {
- return false;
- }
- }
-
- /**
- * Returns true is this object is representing a true state.
- */
- public boolean isSet() {
- this.ensureAtLeastPartResolved();
- return flag;
- }
-
- public void parseUserEntry(final String text) throws ValueParseException {
- if (text.trim().equals("")) {
- clear();
- } else {
- if ("true".startsWith(text.toLowerCase())) {
- set();
- } else {
- reset();
- }
- }
- }
-
- /**
- * Resets the objects state to false.
- */
- public void reset() {
- setValuesInternal(false, false, true);
- }
-
- public void restoreFromEncodedString(final String data) {
- if (data == null || data.equals("NULL")) {
- setValuesInternal(false, true, false);
- } else {
- setValuesInternal(data.equals("true"), false, false);
- }
- }
-
- public String asEncodedString() {
- if (isEmpty()) {
- return "NULL";
- } else {
- return isSet() ? "true" : "false";
- }
- }
-
- /**
- * Sets the objects state to true.
- */
- public void set() {
- setValue(true);
- }
-
- public void setValue(final boolean set) {
- setValuesInternal(set, false, true);
- }
-
- public void setValue(final Logical value) {
- if (value == null) {
- this.clear();
- } else {
- setValuesInternal(value.flag, value.isNull, true);
- }
- }
-
- private void setValuesInternal(final boolean value, final boolean isNull, final boolean notify) {
- if (notify) {
- ensureAtLeastPartResolved();
- }
- this.flag = value;
- this.isNull = isNull;
- if (notify) {
- parentChanged();
- }
- }
-
- public Title title() {
- return new Title(isEmpty() ? "" : (flag ? "TRUE" : "FALSE"));
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/Magnitude.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/Magnitude.java b/core/applib/src/main/src-archived/old-valueholders/Magnitude.java
deleted file mode 100644
index c1464b9..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/Magnitude.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.BusinessObject;
-
-
-public abstract class Magnitude extends BusinessValueHolder {
- private static final long serialVersionUID = 1L;
-
- protected Magnitude(final BusinessObject parent) {
- super(parent);
- }
-
- public boolean isBetween(final Magnitude minMagnitude, final Magnitude maxMagnitude) {
- this.ensureAtLeastPartResolved();
- return isGreaterThanOrEqualTo(minMagnitude) && isLessThanOrEqualTo(maxMagnitude);
- }
-
- public abstract boolean isEqualTo(final Magnitude magnitude);
-
- public boolean isGreaterThan(final Magnitude magnitude) {
- this.ensureAtLeastPartResolved();
- return magnitude.isLessThan(this);
- }
-
- public boolean isGreaterThanOrEqualTo(final Magnitude magnitude) {
- this.ensureAtLeastPartResolved();
- return !isLessThan(magnitude);
- }
-
- public abstract boolean isLessThan(final Magnitude magnitude);
-
- public boolean isLessThanOrEqualTo(final Magnitude magnitude) {
- this.ensureAtLeastPartResolved();
- return !isGreaterThan(magnitude);
- }
-
- public Magnitude max(final Magnitude magnitude) {
- this.ensureAtLeastPartResolved();
- return isGreaterThan(magnitude) ? this : magnitude;
- }
-
- public Magnitude min(final Magnitude magnitude) {
- this.ensureAtLeastPartResolved();
- return isLessThan(magnitude) ? this : magnitude;
- }
-
- /**
- * delegates the comparsion to the <code>isEqualTo</code> method if specified object is a
- * <code>Magnitude</code> else returns false.
- *
- * @see BusinessValueHolder#isSameAs(BusinessValueHolder)
- */
- public final boolean isSameAs(BusinessValueHolder object) {
- this.ensureAtLeastPartResolved();
- if (object instanceof Magnitude) {
- return isEqualTo((Magnitude) object);
- } else {
- return false;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/Money.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/Money.java b/core/applib/src/main/src-archived/old-valueholders/Money.java
deleted file mode 100644
index acef65b..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/Money.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.BusinessObject;
-import org.apache.isis.application.Title;
-import org.apache.isis.application.value.ValueParseException;
-
-import java.text.NumberFormat;
-import java.text.ParseException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * Value object representing a monetary value including a currency type.
- * <p>
- * This object <i>does</i> support value listeners
- * </p>
- */
-public class Money extends Magnitude { // implements java.io.Externalizable {
- private static final long serialVersionUID = 1L;
- private static final NumberFormat CURRENCY_FORMAT = NumberFormat.getCurrencyInstance();
- private static final NumberFormat NUMBER_FORMAT = NumberFormat.getNumberInstance();
- private boolean isNull;
- private double amount;
-
- /**
- * Create a Money with zero value.
- */
- public Money() {
- this(null, 0);
- }
-
- /**
- * Create a Money object with the same value as the specified object.
- */
- public Money(final Money money) {
- this(null, money);
- }
-
- public Money(final double amount) {
- this(null, amount);
- }
-
- /**
- * Create a Money with zero value.
- */
- public Money(final BusinessObject parent) {
- super(parent);
- setValue(0);
- }
-
- /**
- * Create a Money object with the same value as the specified object.
- */
- public Money(final BusinessObject parent, final Money money) {
- super(parent);
- setValue(money);
- }
-
- public Money(final BusinessObject parent, final double amount) {
- super(parent);
- setValue(amount);
- }
-
- /**
- * Add the specified money to this money.
- */
- public void add(final Money money) {
- setValue(doubleValue() + money.amount);
- }
-
- public void clear() {
- setValuesInternal(0, true, true);
- }
-
- /**
- * Copies the specified object's contained data to this instance.
- *
- * @param object
- * the object to copy the data from
- */
- public void copyObject(final BusinessValueHolder object) {
- if (object == null) {
- clear();
- } else if (!(object instanceof Money)) {
- throw new IllegalArgumentException("Can only copy the value of a Money object");
- } else {
- setValue((Money) object);
- }
-
- }
-
- /**
- * Divides this value by the specified amount.
- */
- public void divideBy(final double operand) {
- // amount /= operand;
- setValue(doubleValue() / operand);
- }
-
- public double doubleValue() {
- ensureAtLeastPartResolved();
- return amount;
- }
-
- public boolean equals(final Object obj) {
- ensureAtLeastPartResolved();
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof Money)) {
- return false;
- }
- Money object = (Money) obj;
- if (object.isEmpty() && isEmpty()) {
- return true;
- }
- return object.amount == amount;
- }
-
- /**
- * Returns this value as an float.
- */
- public float floatValue() {
- ensureAtLeastPartResolved();
- return (float) amount;
- }
-
- public String getObjectHelpText() {
- return "A Money object stored as dollars/cents, pounds/pence, euro/cents.";
- }
-
- /**
- * Returns this value as an int.
- */
- public int intValue() {
- ensureAtLeastPartResolved();
- return (int) amount;
- }
-
- public boolean isEmpty() {
- ensureAtLeastPartResolved();
- return isNull;
- }
-
- public boolean isGreaterThan(final double amount) {
- return !isLessThanOrEqualTo(amount);
- }
-
- public boolean isGreaterThanOrEqualTo(final double amount) {
- return !isLessThan(amount);
- }
-
- public boolean isEqualTo(final Magnitude magnitude) {
- ensureAtLeastPartResolved();
- if (magnitude instanceof Money) {
- if (isNull) {
- return magnitude.isEmpty();
- }
-
- return ((Money) magnitude).amount == amount;
- } else {
- throw new IllegalArgumentException("Parameter must be of type Money");
- }
- }
-
- public boolean isLessThan(final Magnitude magnitude) {
- ensureAtLeastPartResolved();
- if (magnitude instanceof Money) {
- return !isEmpty() && !magnitude.isEmpty() && (amount < ((Money) magnitude).amount);
- } else {
- throw new IllegalArgumentException("Parameter must be of type Money");
- }
- }
-
- public boolean isLessThan(final double amount) {
- return !isEmpty() && this.amount < amount;
- }
-
- public boolean isLessThanOrEqualTo(final double amount) {
- return !isEmpty() && this.amount <= amount;
- }
-
- /**
- * Returns true if this value is less than zero.
- */
- public boolean isNegative() {
- ensureAtLeastPartResolved();
- return amount < 0.0;
- }
-
- /**
- * Returns this value as an long.
- */
- public long longValue() {
- ensureAtLeastPartResolved();
- return (long) amount;
- }
-
- /**
- * Multiply this value by the specified amount.
- */
- public void multiplyBy(final double operand) {
- // amount *= operand;
- setValue(doubleValue() * operand);
- }
-
- public void parseUserEntry(final String text) throws ValueParseException {
- if (text.trim().equals("")) {
- clear();
- } else {
- try {
- // amount = CURRENCY_FORMAT.parse(text).doubleValue();
- setValue(CURRENCY_FORMAT.parse(text).doubleValue());
- } catch (ParseException tryAgain) {
- try {
- // amount = NUMBER_FORMAT.parse(text).doubleValue();
- setValue(NUMBER_FORMAT.parse(text).doubleValue());
- } catch (ParseException e) {
- throw new ValueParseException("Invalid number", e);
- }
- }
- }
- }
-
- /**
- * Reset this money so it contains 0.
- */
- public void reset() {
- setValuesInternal(0, false, true);
- }
-
- /**
- * Set this value to have the specified values.
- */
- public void setValue(final double amount) {
- setValuesInternal(amount, false, true);
- }
-
- /**
- * Set this value to be the same as the specified value.
- */
- public void setValue(final Money value) {
- setValuesInternal(value.doubleValue(), value.isNull, true);
- }
-
- private void setValuesInternal(final double value, final boolean isNull, final boolean notify) {
- if (notify) {
- ensureAtLeastPartResolved();
- }
- this.amount = value;
- this.isNull = isNull;
- if (notify) {
- parentChanged();
- }
- }
-
- /**
- * Returns this value as an short.
- */
- public short shortValue() {
- ensureAtLeastPartResolved();
- return (short) amount;
- }
-
- /**
- * Subtract the specified amount from this value.
- */
- public void subtract(final Money money) {
- // checkCanOperate();
- // amount -= money.amount;
- setValue(doubleValue() - money.amount);
- }
-
- public Title title() {
- return new Title(isEmpty() ? "" : CURRENCY_FORMAT.format(amount));
- }
-
- public void restoreFromEncodedString(final String data) {
- if (data == null || data.equals("NULL")) {
- setValuesInternal(0, true, false);
- } else {
- setValuesInternal(Double.valueOf(data).doubleValue(), false, false);
- }
- }
-
- public String asEncodedString() {
- // note: isEmpty does this.ensureAtLeastPartResolved();
- if (isEmpty()) {
- return "NULL";
- } else {
- return String.valueOf(doubleValue());
- }
- }
-
- public LoggerFactory.getLogger() {
- return logger;
- }
-
- private final static Logger logger = LoggerFactory.getLogger(Money.class);
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/MoneyTest.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/MoneyTest.java b/core/applib/src/main/src-archived/old-valueholders/MoneyTest.java
deleted file mode 100644
index 4546109..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/MoneyTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-public class MoneyTest extends ValueTestCase {
-
- public void testSaveRestore() throws Exception {
- Money money1 = new Money();
- money1.parseUserEntry("2003-1-4");
- assertFalse(money1.isEmpty());
-
- Money money2 = new Money();
- money2.restoreFromEncodedString(money1.asEncodedString());
- assertEquals(money1.floatValue(), money2.floatValue(), 0.0);
- assertFalse(money2.isEmpty());
- }
-
- public void testSaveRestorOfNull() throws Exception {
- Money money1 = new Money();
- money1.clear();
- assertTrue("Money isEmpty", money1.isEmpty());
-
- Money money2 = new Money();
- money2.restoreFromEncodedString(money1.asEncodedString());
- assertEquals(money1.floatValue(), money2.floatValue(), 0.0);
- assertTrue(money2.isEmpty());
- }
-
- public void testComparisons() {
- Money money = new Money(5.00);
- assertTrue("> 1", money.isGreaterThan(1.00));
- assertTrue(">= 5", money.isGreaterThanOrEqualTo(5.00));
- assertTrue(">= 4.9", money.isGreaterThanOrEqualTo(4.90));
- assertTrue("not >= 5.1", !money.isGreaterThanOrEqualTo(5.10));
-
- assertTrue("< 5.1", money.isLessThan(5.10));
- assertTrue("<= 5.1", money.isLessThanOrEqualTo(5.10));
- assertTrue("<= 5", money.isLessThanOrEqualTo(5.00));
-
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/MultilineTextString.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/MultilineTextString.java b/core/applib/src/main/src-archived/old-valueholders/MultilineTextString.java
deleted file mode 100644
index 43e2ed1..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/MultilineTextString.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.BusinessObject;
-
-
-public class MultilineTextString extends TextString {
- private static final long serialVersionUID = 1L;
-
- /**
- *
- */
- public MultilineTextString() {
- super();
- }
-
- /**
- * @param text
- */
- public MultilineTextString(final String text) {
- super(text);
- }
-
- /**
- * @param textString
- */
- public MultilineTextString(final MultilineTextString textString) {
- super(textString);
- }
-
- /**
- *
- */
- public MultilineTextString(final BusinessObject parent) {
- super(parent);
- }
-
- /**
- * @param text
- */
- public MultilineTextString(final BusinessObject parent, final String text) {
- super(parent, text);
- }
-
- /**
- * @param textString
- */
- public MultilineTextString(final BusinessObject parent, final MultilineTextString textString) {
- super(parent, textString);
- }
-
- /*
- * @see org.apache.isis.object.value.TextString#setValue(java.lang.String)
- */
- public void setValue(final String text) {
- super.setValue(convertLineEnding(text));
- }
-
- public void restoreFromEncodedString(final String data) {
- super.restoreFromEncodedString(convertLineEnding(data));
- }
-
- protected boolean isCharDisallowed(final char c) {
- return c == '\r';
- }
-
- private String convertLineEnding(final String original) {
- if (original == null)
- return null;
- /*
- * convert all line ending to LF e.g. CR -> LF CRLF -> LF
- */
- StringBuffer text = new StringBuffer(original.length());
-
- for (int i = 0; i < original.length(); i++) {
- if (original.charAt(i) == '\r') {
- text.append('\n');
-
- // skip next char if LF (ie is a CRLF sequence
- if (i + 1 < original.length() && original.charAt(i + 1) == '\n') {
- i++;
- }
- } else {
- text.append(original.charAt(i));
- }
- }
-
- return text.toString();
- }
-
- /*
- * int numberOfLine() int maxWidth();
- *
- */
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/MultilineTextStringTests.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/MultilineTextStringTests.java b/core/applib/src/main/src-archived/old-valueholders/MultilineTextStringTests.java
deleted file mode 100644
index 8242459..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/MultilineTextStringTests.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-public class MultilineTextStringTests extends ValueTestCase {
-
- public static void main(final String[] args) {
- junit.textui.TestRunner.run(MultilineTextStringTests.class);
- }
-
- public void testInvalidCharacters() {
-
- MultilineTextString t = new MultilineTextString("Hello\r");
- assertEquals("Hello\n", t.stringValue());
-
- t = new MultilineTextString("Hello\r\n");
- assertEquals("Hello\n", t.stringValue());
-
- t = new MultilineTextString("Hello\n\r");
- assertEquals("Hello\n\n", t.stringValue());
- }
-
- public void testTitle() {
- String text = "Hello\nYou";
- MultilineTextString t = new MultilineTextString(text);
- assertEquals("Hello\nYou", t.title().toString());
-
- }
-
- public void testValidCharacters() {
- String text = "Hello\tYou\n";
- MultilineTextString t = new MultilineTextString(text);
- assertEquals(text, t.stringValue());
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/Option.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/Option.java b/core/applib/src/main/src-archived/old-valueholders/Option.java
deleted file mode 100644
index 3d3381c..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/Option.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.BusinessObject;
-import org.apache.isis.application.Title;
-import org.apache.isis.application.value.ValueParseException;
-
-
-/**
- * Value object representing one of a number of choices. The options are specified as strings.
- * <p>
- * NOTE: this class currently does not support about listeners.
- * </p>
- */
-public class Option extends BusinessValueHolder {
- private String[] options;
- private int selection;
-
- public Option() {
- this((BusinessObject) null);
- }
-
- public Option(final String[] options) {
- this(null, options, 0);
- }
-
- public Option(final String[] options, final int selected) {
- this(null, options, selected);
- }
-
- public Option(final BusinessObject parent) {
- this(parent, new String[] { "" }, 0);
- }
-
- public Option(final BusinessObject parent, final String[] options) {
- this(parent, options, 0);
- }
-
- public Option(final BusinessObject parent, final String[] options, final int selected) {
- super(parent);
- if ((options == null) || (options.length == 0)) {
- throw new IllegalArgumentException("Options array must exist and have at least one element");
- }
-
- this.options = options;
- selection = selected;
- }
-
- public void clear() {
- setSelectionInternal(-1, true);
- }
-
- /**
- * Copies the specified object's contained data to this instance. param object the object to copy the data
- * from
- */
- public void copyObject(final BusinessValueHolder object) {
- if (!(object instanceof Option)) {
- throw new IllegalArgumentException("Can only copy the value of a SelectionObject object");
- }
-
- setSelectionIndex(((Option) object).selection);
- }
-
- public boolean equals(final Object obj) {
- ensureAtLeastPartResolved();
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof Option)) {
- return false;
- }
- Option object = (Option) obj;
- if (object.isEmpty() && isEmpty()) {
- return true;
- }
- return object.selection == selection;
- }
-
- public String getObjectHelpText() {
- return "A Selection object.";
- }
-
- public String getOption(final int index) {
- return options[index];
- }
-
- public String getOptionAt(final int index) {
- return options[index];
- }
-
- public String[] getOptions() {
- return options;
- }
-
- public String getSelection() {
- return isEmpty() ? "" : options[selection];
- }
-
- public int getSelectionIndex() {
- ensureAtLeastPartResolved();
- return selection;
- }
-
- public boolean isEmpty() {
- ensureAtLeastPartResolved();
- return selection == -1;
- }
-
- /**
- * Compares the selected options if the specified object is a <code>Option</code> object else returns
- * false.
- *
- * @see BusinessValueHolder#isSameAs(BusinessValueHolder)
- */
- public boolean isSameAs(final BusinessValueHolder object) {
- ensureAtLeastPartResolved();
- if (object instanceof Option) {
- return ((Option) object).getSelection().equals(getSelection());
- } else {
- return false;
- }
- }
-
- public int noOptions() {
- return options.length;
- }
-
- public void parseUserEntry(final String text) throws ValueParseException {
- setSelection(text);
- }
-
- /**
- * Reset this option so it has the first option selected.
- *
- */
- public void reset() {
- setSelectionInternal(0, true);
- }
-
- public void setSelection(final String selection) {
- setSelectionInternal(selection, true);
- }
-
- public void setSelectionIndex(final int selection) {
- if ((0 > selection) && (selection >= options.length)) {
- throw new IllegalArgumentException("Selection value must index one of the available options");
- }
-
- setSelectionInternal(selection, true);
- }
-
- private void setSelectionInternal(final int selection, final boolean notify) {
- if (notify) {
- ensureAtLeastPartResolved();
- }
- this.selection = selection;
- if (notify) {
- parentChanged();
- }
- }
-
- private void setSelectionInternal(final String selection, final boolean notify) {
- if (notify) {
- ensureAtLeastPartResolved();
- }
- for (int i = 0; i < options.length; i++) {
- if (options[i].equalsIgnoreCase(selection)) {
- this.selection = i;
-
- break;
- }
- }
- if (notify) {
- parentChanged();
- }
- }
-
- public String stringValue() {
- return getSelection();
- }
-
- public Title title() {
- ensureAtLeastPartResolved();
- return new Title((options == null) ? "none" : ((selection >= 0) ? options[selection] : ""));
- }
-
- public boolean hasOption(final String expectedTitle) {
- for (int i = 0; i < options.length; i++) {
- if (options[i].equalsIgnoreCase(expectedTitle)) {
- return true;
- }
- }
-
- return false;
- }
-
- public void restoreFromEncodedString(final String data) {
- if (data == null || data.equals("NULL")) {
- setSelectionInternal(-1, false);
- } else {
- setSelectionInternal(data, false);
- }
- }
-
- public String asEncodedString() {
- return isEmpty() ? "NULL" : getSelection();
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/Password.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/Password.java b/core/applib/src/main/src-archived/old-valueholders/Password.java
deleted file mode 100644
index 0314947..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/Password.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.BusinessObject;
-import org.apache.isis.application.Title;
-import org.apache.isis.application.value.ValueParseException;
-
-
-public class Password extends BusinessValueHolder {
- private static final long serialVersionUID = 1L;
- private int maximumLength;
- private String password;
-
- public Password() {
- this(null);
- }
-
- public Password(final int maximumLength) {
- this(null, maximumLength);
- }
-
- public Password(final BusinessObject parent) {
- super(parent);
- password = "";
- }
-
- public Password(final BusinessObject parent, final int maximumLength) {
- this(parent);
- this.maximumLength = maximumLength;
- }
-
- public String asEncodedString() {
- return isEmpty() ? "NULL" : password;
- }
-
- public void clear() {
- setValuesInternal(null, true);
- }
-
- public void copyObject(final BusinessValueHolder object) {
- if (object == null) {
- this.clear();
- } else if (!(object instanceof Password)) {
- throw new IllegalArgumentException("Can only copy the value of a Password object");
- } else {
- setValue(((Password) object).password);
- }
- }
-
- public int getMaximumLength() {
- return maximumLength;
- }
-
- public boolean isEmpty() {
- ensureAtLeastPartResolved();
- return password == null;
- }
-
- public boolean isSameAs(final BusinessValueHolder object) {
- ensureAtLeastPartResolved();
- if (object instanceof Password) {
- String pswd = ((Password) object).password;
- if (pswd == null && password == null) {
- return true;
- }
- if (password != null && password.equals(pswd)) {
- return true;
- }
- }
- return false;
- }
-
- public void parseUserEntry(final String text) throws ValueParseException {
- setValue(text);
- }
-
- public void reset() {
- setValuesInternal(null, true);
- }
-
- public void restoreFromEncodedString(final String data) {
- if (data == null || data.equals("NULL")) {
- setValuesInternal(null, false);
- } else {
- setValuesInternal(data, false);
- }
- }
-
- public void setMaximumLength(final int maximumLength) {
- this.maximumLength = maximumLength;
- }
-
- public void setValue(final String password) {
- if (password == null) {
- clear();
- } else {
- setValuesInternal(password, false);
- }
- }
-
- private void setValuesInternal(final String value, final boolean notify) {
- if (notify) {
- ensureAtLeastPartResolved();
- }
- this.password = value;
- if (notify) {
- parentChanged();
- }
- }
-
- public String stringValue() {
- ensureAtLeastPartResolved();
- return password;
- }
-
- public Title title() {
- ensureAtLeastPartResolved();
- return new Title(password);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/Percentage.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/Percentage.java b/core/applib/src/main/src-archived/old-valueholders/Percentage.java
deleted file mode 100644
index 3204607..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/Percentage.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.application.valueholder;
-
-import org.apache.isis.application.BusinessObject;
-import org.apache.isis.application.Title;
-import org.apache.isis.application.value.ValueParseException;
-
-import java.text.NumberFormat;
-import java.text.ParseException;
-
-
-/**
- * Value object representing a percentage value.
- * <p>
- * NOTE: this class currently does not support about listeners.
- * </p>
- */
-public class Percentage extends Magnitude {
- private static final long serialVersionUID = 1L;
- private static final NumberFormat PERCENTAGE_FORMAT = NumberFormat.getPercentInstance();
- private static final NumberFormat DECIMAL_FORMAT = NumberFormat.getNumberInstance();
- private float value;
- private boolean isNull;
-
- public Percentage() {
- this(null, 0.0f);
- }
-
- public Percentage(final float value) {
- this(null, value);
- }
-
- /**
- * @deprecated
- */
- public Percentage(final String text) {
- super(null);
- try {
- parseUserEntry(text);
- isNull = false;
- } catch (ValueParseException e) {
- throw new IllegalArgumentException("Could not parse value: " + text);
- }
- }
-
- public Percentage(final Percentage value) {
- this(null, value);
- }
-
- public Percentage(final BusinessObject parent) {
- this(parent, 0.0f);
- }
-
- public Percentage(final BusinessObject parent, final float value) {
- super(parent);
- this.value = value;
- isNull = false;
- }
-
- public Percentage(final BusinessObject parent, final Percentage value) {
- super(parent);
- this.isNull = value.isNull;
- this.value = value.value;
- }
-
- public void add(final double value) {
- setValue((float) (floatValue() + value));
- }
-
- public void clear() {
- setValuesInternal(0F, true, true);
- }
-
- /**
- * Copies the specified object's contained data to this instance. param object the object to copy the data
- * from
- */
- public void copyObject(final BusinessValueHolder object) {
- if (!(object instanceof Percentage)) {
- throw new IllegalArgumentException("Can only copy the value of a Percentage object");
- }
- setValue((Percentage) object);
- }
-
- public void divide(final double value) {
- setValue((float) (floatValue() / value));
- }
-
- /**
- * Returns this value as an double.
- */
- public double doubleValue() {
- ensureAtLeastPartResolved();
- return value;
- }
-
- public boolean equals(final Object obj) {
- ensureAtLeastPartResolved();
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof Percentage)) {
- return false;
- }
- Percentage object = (Percentage) obj;
- if (object.isEmpty() && isEmpty()) {
- return true;
- }
- return object.value == value;
- }
-
- /**
- * Returns this value as an float.
- */
- public float floatValue() {
- ensureAtLeastPartResolved();
- return value;
- }
-
- public String getObjectHelpText() {
- return "A floating point number object.";
- }
-
- /**
- * Returns this value as an int.
- */
- public int intValue() {
- ensureAtLeastPartResolved();
- return (int) value;
- }
-
- public boolean isEmpty() {
- ensureAtLeastPartResolved();
- return isNull;
- }
-
- /**
- */
- public boolean isEqualTo(final Magnitude magnitude) {
- ensureAtLeastPartResolved();
- if (magnitude instanceof Percentage) {
- if (isNull) {
- return magnitude.isEmpty();
- }
- return ((Percentage) magnitude).value == value;
- } else {
- throw new IllegalArgumentException("Parameter must be of type WholeNumber");
- }
- }
-
- public boolean isLessThan(final Magnitude magnitude) {
- if (magnitude instanceof Percentage) {
- return !isEmpty() && !magnitude.isEmpty() && value < ((Percentage) magnitude).value;
- } else {
- throw new IllegalArgumentException("Parameter must be of type WholeNumber");
- }
- }
-
- /**
- * Returns this value as an long.
- */
- public long longValue() {
- ensureAtLeastPartResolved();
- return (long) value;
- }
-
- public void multiply(final double value) {
- setValue((float) (floatValue() * value));
- }
-
- public void parseUserEntry(final String text) throws ValueParseException {
- if (text.trim().equals("")) {
- clear();
- } else {
- try {
- setValue(PERCENTAGE_FORMAT.parse(text).floatValue());
- } catch (ParseException e) {
- try {
- setValue(DECIMAL_FORMAT.parse(text).floatValue());
- } catch (ParseException ee) {
- throw new ValueParseException("Invalid number; can;t parse '" + text + "'", ee);
- }
- }
- }
- }
-
- /**
- * Reset this percentage so it contains 0%.
- */
- public void reset() {
- setValuesInternal(0F, false, true);
- }
-
- public void setValue(final float value) {
- setValuesInternal(value, false, true);
- }
-
- public void setValue(final Percentage value) {
- setValuesInternal(value.floatValue(), value.isNull, true);
- }
-
- private void setValuesInternal(final float value, final boolean isNull, final boolean notify) {
- if (notify) {
- ensureAtLeastPartResolved();
- }
- this.value = value;
- this.isNull = isNull;
- if (notify) {
- parentChanged();
- }
- }
-
- /**
- * Returns this value as an short.
- */
- public short shortValue() {
- ensureAtLeastPartResolved();
- return (short) value;
- }
-
- public void subtract(final double value) {
- add(-value);
- }
-
- public Title title() {
- return new Title(isEmpty() ? "" : PERCENTAGE_FORMAT.format(value));
- }
-
- public void restoreFromEncodedString(final String data) {
- if (data == null || data.equals("NULL")) {
- setValuesInternal(0F, true, false);
- } else {
- setValuesInternal(Float.valueOf(data).floatValue(), false, false);
- }
- }
-
- public String asEncodedString() {
- return isEmpty() ? "NULL" : String.valueOf(floatValue());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/PhoneNumber.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/PhoneNumber.java b/core/applib/src/main/src-archived/old-valueholders/PhoneNumber.java
deleted file mode 100644
index 7558f10..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/PhoneNumber.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.applib.value;
-
-import java.io.Serializable;
-
-public class PhoneNumber implements Serializable {
- private static final long serialVersionUID = 1L;
- private final String number;
-
- public PhoneNumber(final String text) {
- this.number = text;
- }
-
- public Object getValue() {
- return number;
- }
-
- public String toString() {
- return number;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/52912061/core/applib/src/main/src-archived/old-valueholders/Quantity.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/src-archived/old-valueholders/Quantity.java b/core/applib/src/main/src-archived/old-valueholders/Quantity.java
deleted file mode 100644
index 35084a6..0000000
--- a/core/applib/src/main/src-archived/old-valueholders/Quantity.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-package org.apache.isis.applib.value;
-
-/**
- * Color is simple numerical representation of a color using the amount of red, green and blue (RGB)
- * components. Where there is no basic colors (RGB all equal 0) then you get black; where each color is at
- * maximum (RGB all equal 255) you get white.
- */
-public class Quantity extends Magnitude {
- private static final long serialVersionUID = 1L;
- private final int quantity;
-
- public Quantity(final int quantity) {
- if (quantity <= 0) {
- throw new IllegalArgumentException("Quantity must be positive: " + quantity);
- }
- this.quantity = quantity;
- }
-
- public int intValue() {
- return quantity;
- }
-
- /**
- * returns true if the number of this object has the same value as the specified number
- */
- public boolean isEqualTo(final Magnitude number) {
- if (number instanceof Quantity) {
- return ((Quantity) number).quantity == quantity;
- } else {
- throw new IllegalArgumentException("Parameter must be of type Quantity");
- }
- }
-
- /**
- * Returns true if this value is less than the specified value.
- */
- public boolean isLessThan(final Magnitude value) {
- if (value instanceof Quantity) {
- return quantity < ((Quantity) value).quantity;
- } else {
- throw new IllegalArgumentException("Parameter must be of type Quantity");
- }
- }
-
- public String title() {
- return Integer.toString(quantity);
- }
-}