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:32 UTC
[2/4] ISIS-518,
ISIS-519: deprecating applib's Filter and deleting archived code.
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();
- }
-}