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 2012/12/06 11:10:34 UTC
[12/51] [partial] ISIS-188: moving modules into core
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/applib/src/main/src-archived/old-valueholders/FloatingPointNumber.java
----------------------------------------------------------------------
diff --git a/framework/applib/src/main/src-archived/old-valueholders/FloatingPointNumber.java b/framework/applib/src/main/src-archived/old-valueholders/FloatingPointNumber.java
deleted file mode 100644
index e7a06e1..0000000
--- a/framework/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/dbb64345/framework/applib/src/main/src-archived/old-valueholders/Label.java
----------------------------------------------------------------------
diff --git a/framework/applib/src/main/src-archived/old-valueholders/Label.java b/framework/applib/src/main/src-archived/old-valueholders/Label.java
deleted file mode 100644
index 7cdb1aa..0000000
--- a/framework/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/dbb64345/framework/applib/src/main/src-archived/old-valueholders/Logical.java
----------------------------------------------------------------------
diff --git a/framework/applib/src/main/src-archived/old-valueholders/Logical.java b/framework/applib/src/main/src-archived/old-valueholders/Logical.java
deleted file mode 100644
index 676dc06..0000000
--- a/framework/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/dbb64345/framework/applib/src/main/src-archived/old-valueholders/Magnitude.java
----------------------------------------------------------------------
diff --git a/framework/applib/src/main/src-archived/old-valueholders/Magnitude.java b/framework/applib/src/main/src-archived/old-valueholders/Magnitude.java
deleted file mode 100644
index c1464b9..0000000
--- a/framework/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/dbb64345/framework/applib/src/main/src-archived/old-valueholders/Money.java
----------------------------------------------------------------------
diff --git a/framework/applib/src/main/src-archived/old-valueholders/Money.java b/framework/applib/src/main/src-archived/old-valueholders/Money.java
deleted file mode 100644
index 85c0f95..0000000
--- a/framework/applib/src/main/src-archived/old-valueholders/Money.java
+++ /dev/null
@@ -1,322 +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.apache.log4j.Logger;
-
-
-/**
- * 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 Logger getLogger() {
- return logger;
- }
-
- private final static Logger logger = Logger.getLogger(Money.class);
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/applib/src/main/src-archived/old-valueholders/MoneyTest.java
----------------------------------------------------------------------
diff --git a/framework/applib/src/main/src-archived/old-valueholders/MoneyTest.java b/framework/applib/src/main/src-archived/old-valueholders/MoneyTest.java
deleted file mode 100644
index 4546109..0000000
--- a/framework/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/dbb64345/framework/applib/src/main/src-archived/old-valueholders/MultilineTextString.java
----------------------------------------------------------------------
diff --git a/framework/applib/src/main/src-archived/old-valueholders/MultilineTextString.java b/framework/applib/src/main/src-archived/old-valueholders/MultilineTextString.java
deleted file mode 100644
index 43e2ed1..0000000
--- a/framework/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/dbb64345/framework/applib/src/main/src-archived/old-valueholders/MultilineTextStringTests.java
----------------------------------------------------------------------
diff --git a/framework/applib/src/main/src-archived/old-valueholders/MultilineTextStringTests.java b/framework/applib/src/main/src-archived/old-valueholders/MultilineTextStringTests.java
deleted file mode 100644
index 8242459..0000000
--- a/framework/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/dbb64345/framework/applib/src/main/src-archived/old-valueholders/Option.java
----------------------------------------------------------------------
diff --git a/framework/applib/src/main/src-archived/old-valueholders/Option.java b/framework/applib/src/main/src-archived/old-valueholders/Option.java
deleted file mode 100644
index 3d3381c..0000000
--- a/framework/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/dbb64345/framework/applib/src/main/src-archived/old-valueholders/Password.java
----------------------------------------------------------------------
diff --git a/framework/applib/src/main/src-archived/old-valueholders/Password.java b/framework/applib/src/main/src-archived/old-valueholders/Password.java
deleted file mode 100644
index 0314947..0000000
--- a/framework/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/dbb64345/framework/applib/src/main/src-archived/old-valueholders/Percentage.java
----------------------------------------------------------------------
diff --git a/framework/applib/src/main/src-archived/old-valueholders/Percentage.java b/framework/applib/src/main/src-archived/old-valueholders/Percentage.java
deleted file mode 100644
index 3204607..0000000
--- a/framework/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/dbb64345/framework/applib/src/main/src-archived/old-valueholders/PhoneNumber.java
----------------------------------------------------------------------
diff --git a/framework/applib/src/main/src-archived/old-valueholders/PhoneNumber.java b/framework/applib/src/main/src-archived/old-valueholders/PhoneNumber.java
deleted file mode 100644
index 7558f10..0000000
--- a/framework/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/dbb64345/framework/applib/src/main/src-archived/old-valueholders/Quantity.java
----------------------------------------------------------------------
diff --git a/framework/applib/src/main/src-archived/old-valueholders/Quantity.java b/framework/applib/src/main/src-archived/old-valueholders/Quantity.java
deleted file mode 100644
index 35084a6..0000000
--- a/framework/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);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/applib/src/main/src-archived/old-valueholders/RtfValue.java
----------------------------------------------------------------------
diff --git a/framework/applib/src/main/src-archived/old-valueholders/RtfValue.java b/framework/applib/src/main/src-archived/old-valueholders/RtfValue.java
deleted file mode 100644
index 4d5ad03..0000000
--- a/framework/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/dbb64345/framework/applib/src/main/src-archived/old-valueholders/SerialNumber.java
----------------------------------------------------------------------
diff --git a/framework/applib/src/main/src-archived/old-valueholders/SerialNumber.java b/framework/applib/src/main/src-archived/old-valueholders/SerialNumber.java
deleted file mode 100644
index ffcbb3a..0000000
--- a/framework/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/dbb64345/framework/applib/src/main/src-archived/old-valueholders/SimpleState.java
----------------------------------------------------------------------
diff --git a/framework/applib/src/main/src-archived/old-valueholders/SimpleState.java b/framework/applib/src/main/src-archived/old-valueholders/SimpleState.java
deleted file mode 100644
index 4f6eb96..0000000
--- a/framework/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/dbb64345/framework/applib/src/main/src-archived/old-valueholders/TestClock.java
----------------------------------------------------------------------
diff --git a/framework/applib/src/main/src-archived/old-valueholders/TestClock.java b/framework/applib/src/main/src-archived/old-valueholders/TestClock.java
deleted file mode 100644
index a2e8a39..0000000
--- a/framework/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();
- }
-
-}