You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2009/11/11 16:23:45 UTC
svn commit: r834907 - in /incubator/pivot/trunk/core:
src/org/apache/pivot/collections/ src/org/apache/pivot/util/
src/org/apache/pivot/xml/ test/org/apache/pivot/util/test/
Author: gbrown
Date: Wed Nov 11 15:23:45 2009
New Revision: 834907
URL: http://svn.apache.org/viewvc?rev=834907&view=rev
Log:
Add stub support for org.apache.pivot.xml classes.
Added:
incubator/pivot/trunk/core/src/org/apache/pivot/xml/
incubator/pivot/trunk/core/src/org/apache/pivot/xml/Element.java
incubator/pivot/trunk/core/src/org/apache/pivot/xml/ElementListener.java
incubator/pivot/trunk/core/src/org/apache/pivot/xml/Node.java
incubator/pivot/trunk/core/src/org/apache/pivot/xml/NodeListener.java
incubator/pivot/trunk/core/src/org/apache/pivot/xml/TextNode.java
incubator/pivot/trunk/core/src/org/apache/pivot/xml/XMLSerializer.java
incubator/pivot/trunk/core/test/org/apache/pivot/util/test/TimeTest.java
Modified:
incubator/pivot/trunk/core/src/org/apache/pivot/collections/Sequence.java
incubator/pivot/trunk/core/src/org/apache/pivot/util/Time.java
Modified: incubator/pivot/trunk/core/src/org/apache/pivot/collections/Sequence.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/src/org/apache/pivot/collections/Sequence.java?rev=834907&r1=834906&r2=834907&view=diff
==============================================================================
--- incubator/pivot/trunk/core/src/org/apache/pivot/collections/Sequence.java (original)
+++ incubator/pivot/trunk/core/src/org/apache/pivot/collections/Sequence.java Wed Nov 11 15:23:45 2009
@@ -194,17 +194,11 @@
normalize();
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean hasNext() {
return (stack.peek() != null);
}
- /**
- * {@inheritDoc}
- */
@Override
@SuppressWarnings("unchecked")
public T next() {
@@ -258,17 +252,11 @@
}
}
- /**
- * {@inheritDoc}
- */
@Override
public void remove() {
throw new UnsupportedOperationException();
}
- /**
- * {@inheritDoc}
- */
@Override
public Path getPath() {
if (previousPath == null) {
@@ -317,8 +305,7 @@
* sequence.
*/
@SuppressWarnings("unchecked")
- public static <T> void insert(Sequence<T> sequence, T item, Path path,
- int index) {
+ public static <T> void insert(Sequence<T> sequence, T item, Path path, int index) {
((Sequence<T>)get(sequence, path)).insert(item, index);
}
Modified: incubator/pivot/trunk/core/src/org/apache/pivot/util/Time.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/src/org/apache/pivot/util/Time.java?rev=834907&r1=834906&r2=834907&view=diff
==============================================================================
--- incubator/pivot/trunk/core/src/org/apache/pivot/util/Time.java (original)
+++ incubator/pivot/trunk/core/src/org/apache/pivot/util/Time.java Wed Nov 11 15:23:45 2009
@@ -245,9 +245,8 @@
}
public Time(int milliseconds) {
- if (milliseconds < 0 || milliseconds > MILLISECONDS_PER_DAY - 1) {
- throw new IllegalArgumentException("Invalid milliseconds.");
- }
+ milliseconds %= MILLISECONDS_PER_DAY;
+ milliseconds = (milliseconds + MILLISECONDS_PER_DAY) % MILLISECONDS_PER_DAY;
hour = milliseconds / MILLISECONDS_PER_HOUR;
milliseconds %= MILLISECONDS_PER_HOUR;
@@ -273,15 +272,7 @@
* The resulting time.
*/
public Time add(int milliseconds) {
- milliseconds += toMilliseconds();
-
- milliseconds %= MILLISECONDS_PER_DAY;
-
- if (milliseconds < 0) {
- milliseconds += MILLISECONDS_PER_DAY;
- }
-
- return new Time(milliseconds);
+ return new Time(toMilliseconds() + milliseconds);
}
/**
Added: incubator/pivot/trunk/core/src/org/apache/pivot/xml/Element.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/src/org/apache/pivot/xml/Element.java?rev=834907&view=auto
==============================================================================
--- incubator/pivot/trunk/core/src/org/apache/pivot/xml/Element.java (added)
+++ incubator/pivot/trunk/core/src/org/apache/pivot/xml/Element.java Wed Nov 11 15:23:45 2009
@@ -0,0 +1,310 @@
+/*
+ * 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.pivot.xml;
+
+import java.util.Comparator;
+import java.util.Iterator;
+
+import org.apache.pivot.collections.Dictionary;
+import org.apache.pivot.collections.List;
+import org.apache.pivot.collections.ListListener;
+import org.apache.pivot.collections.Sequence;
+import org.apache.pivot.util.ListenerList;
+
+/**
+ * Node class representing an XML element.
+ */
+public class Element extends Node implements List<Node>, Dictionary<String, String> {
+ /**
+ * Dictionary representing the namespaces declared by this element.
+ */
+ public class NamespaceDictionary implements Dictionary<String, String> {
+ private NamespaceDictionary() {
+ }
+
+ @Override
+ public String get(String prefix) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String put(String prefix, String uri) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String remove(String prefix) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean containsKey(String prefix) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isEmpty() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+ }
+
+ private static class ElementListenerList extends ListenerList<ElementListener>
+ implements ElementListener {
+ public void namespacePrefixChanged(Element element, String previousNamespacePrefix) {
+ for (ElementListener listener : this) {
+ listener.namespacePrefixChanged(element, previousNamespacePrefix);
+ }
+ }
+
+ public void localNameChanged(Element element, String previousLocalName) {
+ for (ElementListener listener : this) {
+ listener.localNameChanged(element, previousLocalName);
+ }
+ }
+
+ public void attributeAdded(Element element, String attribute) {
+ for (ElementListener listener : this) {
+ listener.attributeAdded(element, attribute);
+ }
+ }
+
+ public void attributeUpdated(Element element, String attribute, String previousValue) {
+ for (ElementListener listener : this) {
+ listener.attributeUpdated(element, attribute, previousValue);
+ }
+ }
+
+ public void attributeRemoved(Element element, String attribute) {
+ for (ElementListener listener : this) {
+ listener.attributeRemoved(element, attribute);
+ }
+ }
+
+ public void namespaceAdded(Element element, String prefix) {
+ for (ElementListener listener : this) {
+ listener.namespaceAdded(element, prefix);
+ }
+ }
+
+ public void namespaceUpdated(Element element, String prefix, String previousURI) {
+ for (ElementListener listener : this) {
+ listener.namespaceUpdated(element, prefix, previousURI);
+ }
+ }
+
+ public void namespaceRemoved(Element element, String prefix) {
+ for (ElementListener listener : this) {
+ listener.namespaceRemoved(element, prefix);
+ }
+ }
+ }
+
+ private String namespacePrefix;
+ private String localName;
+
+ private ElementListenerList elementListeners = new ElementListenerList();
+
+ public Element(String localName) {
+ this(null, localName);
+ }
+
+ public Element(String namespacePrefix, String localName) {
+ setNamespacePrefix(namespacePrefix);
+ setLocalName(localName);
+ }
+
+ /**
+ * Returns the fully-qualified name of the element.
+ */
+ public String getName() {
+ String name;
+ if (namespacePrefix == null) {
+ name = localName;
+ } else {
+ name = namespacePrefix + ":" + localName;
+ }
+
+ return name;
+ }
+
+ public String getNamespacePrefix() {
+ return namespacePrefix;
+ }
+
+ public void setNamespacePrefix(String namespacePrefix) {
+ if (namespacePrefix != null) {
+ // TODO Validate name
+
+ if (getNamespaceURI(namespacePrefix) == null) {
+ throw new IllegalArgumentException("Namespace \"" + namespacePrefix + "\" does not exist.");
+ }
+ }
+
+ String previousNamespacePrefix = this.namespacePrefix;
+
+ if (previousNamespacePrefix != namespacePrefix) {
+ this.namespacePrefix = namespacePrefix;
+ elementListeners.namespacePrefixChanged(this, previousNamespacePrefix);
+ }
+ }
+
+ public String getNamespaceURI() {
+ return (namespacePrefix == null) ? null : getNamespaceURI(namespacePrefix);
+ }
+
+ public String getNamespaceURI(String prefix) {
+ // TODO Walk up parent tree looking for namespace prefix
+ return null;
+ }
+
+ public String getLocalName() {
+ return localName;
+ }
+
+ public void setLocalName(String localName) {
+ if (localName == null) {
+ throw new IllegalArgumentException();
+ }
+
+ // TODO Validate name
+
+ String previousLocalName = this.localName;
+
+ if (previousLocalName != localName) {
+ this.localName = localName;
+ elementListeners.localNameChanged(this, previousLocalName);
+ }
+ }
+
+ @Override
+ public String get(String attribute) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String put(String attribute, String value) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String remove(String attribute) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean containsKey(String attribute) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isEmpty() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public int add(Node item) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public void insert(Node item, int index) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Node update(int index, Node item) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int remove(Node item) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public Sequence<Node> remove(int index, int count) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void clear() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Node get(int index) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int indexOf(Node item) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getLength() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public Comparator<Node> getComparator() {
+ return null;
+ }
+
+ @Override
+ public void setComparator(Comparator<Node> comparator) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Iterator<Node> iterator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ListenerList<ListListener<Node>> getListListeners() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * Returns the element listener list.
+ */
+ public ListenerList<ElementListener> getElementListeners() {
+ return elementListeners;
+ }
+}
Added: incubator/pivot/trunk/core/src/org/apache/pivot/xml/ElementListener.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/src/org/apache/pivot/xml/ElementListener.java?rev=834907&view=auto
==============================================================================
--- incubator/pivot/trunk/core/src/org/apache/pivot/xml/ElementListener.java (added)
+++ incubator/pivot/trunk/core/src/org/apache/pivot/xml/ElementListener.java Wed Nov 11 15:23:45 2009
@@ -0,0 +1,117 @@
+/*
+ * 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.pivot.xml;
+
+/**
+ * Element listener interface.
+ */
+public interface ElementListener {
+ /**
+ * Element listener adapter.
+ */
+ public static class Adapter implements ElementListener {
+ public void namespacePrefixChanged(Element element, String previousNamespacePrefix) {
+ }
+
+ public void localNameChanged(Element element, String previousLocalName) {
+ }
+
+ public void attributeAdded(Element element, String attribute) {
+ }
+
+ public void attributeUpdated(Element element, String attribute, String previousValue) {
+ }
+
+ public void attributeRemoved(Element element, String attribute) {
+ }
+
+ public void namespaceAdded(Element element, String prefix) {
+ }
+
+ public void namespaceUpdated(Element element, String prefix, String previousURI) {
+ }
+
+ public void namespaceRemoved(Element element, String prefix) {
+ }
+ }
+
+ /**
+ * Called when an element's namespace prefix has changed.
+ *
+ * @param element
+ * @param previousNamespacePrefix
+ */
+ public void namespacePrefixChanged(Element element, String previousNamespacePrefix);
+
+ /**
+ * Called when an element's local name has changed.
+ *
+ * @param element
+ * @param previousLocalName
+ */
+ public void localNameChanged(Element element, String previousLocalName);
+
+ /**
+ * Called when an attribute has been added to an element.
+ *
+ * @param element
+ * @param attribute
+ */
+ public void attributeAdded(Element element, String attribute);
+
+ /**
+ * Called when an element attribute has been updated.
+ *
+ * @param element
+ * @param attribute
+ * @param previousValue
+ */
+ public void attributeUpdated(Element element, String attribute, String previousValue);
+
+ /**
+ * Called when an attribute has been removed from an element.
+ *
+ * @param element
+ * @param attribute
+ */
+ public void attributeRemoved(Element element, String attribute);
+
+ /**
+ * Called when a namespace has been added to an element.
+ *
+ * @param element
+ * @param prefix
+ */
+ public void namespaceAdded(Element element, String prefix);
+
+ /**
+ * Called when an element attribute has been updated.
+ *
+ * @param element
+ * @param prefix
+ * @param previousURI
+ */
+ public void namespaceUpdated(Element element, String prefix, String previousURI);
+
+ /**
+ * Called when a namespace has been removed from an element.
+ *
+ * @param element
+ * @param prefix
+ */
+ public void namespaceRemoved(Element element, String prefix);
+}
Added: incubator/pivot/trunk/core/src/org/apache/pivot/xml/Node.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/src/org/apache/pivot/xml/Node.java?rev=834907&view=auto
==============================================================================
--- incubator/pivot/trunk/core/src/org/apache/pivot/xml/Node.java (added)
+++ incubator/pivot/trunk/core/src/org/apache/pivot/xml/Node.java Wed Nov 11 15:23:45 2009
@@ -0,0 +1,63 @@
+/*
+ * 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.pivot.xml;
+
+import org.apache.pivot.util.ListenerList;
+
+/**
+ * Abstract base class for XML nodes.
+ */
+public abstract class Node {
+ private static class NodeListenerList extends ListenerList<NodeListener>
+ implements NodeListener {
+ public void parentChanged(Node node, Element previousParent) {
+ for (NodeListener listener : this) {
+ listener.parentChanged(node, previousParent);
+ }
+ }
+ }
+
+ private Element parent = null;
+
+ private NodeListenerList nodeListeners = new NodeListenerList();
+
+ /**
+ * Returns the parent element of the node.
+ */
+ public Element getParent() {
+ return parent;
+ }
+
+ /**
+ * Sets the parent element of the node.
+ *
+ * @param parent
+ */
+ protected void setParent(Element parent) {
+ Element previousParent = this.parent;
+ this.parent = parent;
+
+ nodeListeners.parentChanged(this, previousParent);
+ }
+
+ /**
+ * Returns the node listener list.
+ */
+ public ListenerList<NodeListener> getNodeListeners() {
+ return nodeListeners;
+ }
+}
Added: incubator/pivot/trunk/core/src/org/apache/pivot/xml/NodeListener.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/src/org/apache/pivot/xml/NodeListener.java?rev=834907&view=auto
==============================================================================
--- incubator/pivot/trunk/core/src/org/apache/pivot/xml/NodeListener.java (added)
+++ incubator/pivot/trunk/core/src/org/apache/pivot/xml/NodeListener.java Wed Nov 11 15:23:45 2009
@@ -0,0 +1,30 @@
+/*
+ * 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.pivot.xml;
+
+/**
+ * Node listener interface.
+ */
+public interface NodeListener {
+ /**
+ * Called when a node's parent has changed.
+ *
+ * @param node
+ * @param previousParent
+ */
+ public void parentChanged(Node node, Element previousParent);
+}
Added: incubator/pivot/trunk/core/src/org/apache/pivot/xml/TextNode.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/src/org/apache/pivot/xml/TextNode.java?rev=834907&view=auto
==============================================================================
--- incubator/pivot/trunk/core/src/org/apache/pivot/xml/TextNode.java (added)
+++ incubator/pivot/trunk/core/src/org/apache/pivot/xml/TextNode.java Wed Nov 11 15:23:45 2009
@@ -0,0 +1,36 @@
+/*
+ * 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.pivot.xml;
+
+/**
+ * Class representing an XML text node.
+ */
+public class TextNode extends Node {
+ private String text;
+
+ public TextNode(String text) {
+ if (text == null) {
+ throw new IllegalArgumentException();
+ }
+
+ this.text = text;
+ }
+
+ public String getText() {
+ return text;
+ }
+}
Added: incubator/pivot/trunk/core/src/org/apache/pivot/xml/XMLSerializer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/src/org/apache/pivot/xml/XMLSerializer.java?rev=834907&view=auto
==============================================================================
--- incubator/pivot/trunk/core/src/org/apache/pivot/xml/XMLSerializer.java (added)
+++ incubator/pivot/trunk/core/src/org/apache/pivot/xml/XMLSerializer.java Wed Nov 11 15:23:45 2009
@@ -0,0 +1,49 @@
+/*
+ * 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.pivot.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.pivot.serialization.SerializationException;
+import org.apache.pivot.serialization.Serializer;
+
+/**
+ * Reads and writes XML data.
+ */
+public class XMLSerializer implements Serializer<Element> {
+ public static final String MIME_TYPE = "text/xml";
+
+ @Override
+ public Element readObject(InputStream inputStream) throws IOException, SerializationException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void writeObject(Element object, OutputStream outputStream) throws IOException,
+ SerializationException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public String getMIMEType(Element object) {
+ return MIME_TYPE;
+ }
+}
Added: incubator/pivot/trunk/core/test/org/apache/pivot/util/test/TimeTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/test/org/apache/pivot/util/test/TimeTest.java?rev=834907&view=auto
==============================================================================
--- incubator/pivot/trunk/core/test/org/apache/pivot/util/test/TimeTest.java (added)
+++ incubator/pivot/trunk/core/test/org/apache/pivot/util/test/TimeTest.java Wed Nov 11 15:23:45 2009
@@ -0,0 +1,46 @@
+/*
+ * 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.pivot.util.test;
+
+import org.apache.pivot.util.Time;
+import org.junit.Test;
+
+public class TimeTest {
+ @Test
+ public void basicTest() {
+ Time time = new Time();
+ System.out.println(time);
+
+ time = new Time(time.toMilliseconds());
+ System.out.println(time);
+
+ time = Time.decode(time.toString());
+ System.out.println(time);
+
+ time = new Time(0, 0, 0);
+ System.out.println(time.subtract(new Time(0, 0, 1)));
+ System.out.println(time.subtract(new Time(23, 59, 59, 999)));
+
+ time = new Time(0, 0, 0);
+ System.out.println(time.add(1));
+ System.out.println(time.add(Time.MILLISECONDS_PER_DAY + 1));
+ System.out.println(time.add(-1));
+ System.out.println(time.add(-Time.MILLISECONDS_PER_DAY - 1));
+ System.out.println(time.add(1000));
+ System.out.println(time.add(-1000));
+ }
+}