Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Created v1.5 tag

git-svn-id: https://svn.apache.org/repos/asf/pivot/tags/v1.5@949562 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit d83c9ad2ce19790f75ebe4ed7f3a5bc44bc649e3 2 parents a468a8a + af3d590
Todd Volkert authored
Showing with 659 additions and 396 deletions.
  1. +9 −9 README
  2. +94 −179 RELEASE-NOTES
  3. +5 −5 build.xml
  4. +42 −0 core/src/org/apache/pivot/collections/HashMap.java
  5. +36 −0 core/src/org/apache/pivot/collections/HashSet.java
  6. +90 −0 core/src/org/apache/pivot/xml/Element.java
  7. +24 −0 core/src/org/apache/pivot/xml/TextNode.java
  8. +157 −0 core/src/org/apache/pivot/xml/XML.java
  9. +0 −133 core/src/org/apache/pivot/xml/XMLSerializer.java
  10. +32 −1 core/test/org/apache/pivot/collections/test/HashMapTest.java
  11. +25 −0 core/test/org/apache/pivot/collections/test/HashSetTest.java
  12. +20 −1 core/test/org/apache/pivot/{serialization → json}/test/JSONSerializerTest.java
  13. +24 −0 core/test/org/apache/pivot/json/test/sample.json
  14. +34 −17 core/test/org/apache/pivot/xml/test/XMLSerializerTest.java
  15. +3 −2 demos/src/org/apache/pivot/demos/rss/RSSFeedDemo.java
  16. +4 −4 demos/src/org/apache/pivot/demos/rss/RSSItemRenderer.java
  17. +3 −10 demos/xsl/index.xsl
  18. BIN  etc/pivot.keystore
  19. +16 −0 tests/src/org/apache/pivot/tests/BindableWindow.json
  20. +16 −0 tutorials/src/org/apache/pivot/tutorials/stocktracker/ValueMapping.java
  21. +4 −5 wtk/src/org/apache/pivot/wtk/content/ButtonDataRenderer.java
  22. +4 −5 wtk/src/org/apache/pivot/wtk/content/LinkButtonDataRenderer.java
  23. +4 −5 wtk/src/org/apache/pivot/wtk/content/ListViewItemRenderer.java
  24. +4 −5 wtk/src/org/apache/pivot/wtk/content/MenuBarItemDataRenderer.java
  25. +4 −5 wtk/src/org/apache/pivot/wtk/content/MenuItemDataRenderer.java
  26. +1 −5 wtk/src/org/apache/pivot/wtk/content/SpinnerItemRenderer.java
  27. +4 −5 wtk/src/org/apache/pivot/wtk/content/TreeViewNodeRenderer.java
View
18 README
@@ -16,27 +16,27 @@ in their associated libraries:
Distribution JARs
=================
-* Core (pivot-core-1.4.jar):
+* Core (pivot-core-1.5.jar):
A set of common, non-UI-specific classes.
-* WTK (pivot-wtk-1.4.jar):
+* WTK (pivot-wtk-1.5.jar):
Classes for user interface development, including windows, dialogs, buttons,
lists, text input, layout, drag and drop, XML markup, etc.
-* WTK Terra Theme (pivot-wtk-terra-1.4.jar):
+* WTK Terra Theme (pivot-wtk-terra-1.5.jar):
The default WTK theme provider for Pivot, responsible for the look & feel of
the user interface components.
-* Web (pivot-web-1.4.jar):
+* Web (pivot-web-1.5.jar):
Classes to facilitate communication with remote data services.
-* Web Server (pivot-web-server-1.4.jar):
+* Web Server (pivot-web-server-1.5.jar):
Classes to facilitate implementation of server-side data services.
-* Charting (pivot-charts-1.4.jar):
+* Charting (pivot-charts-1.5.jar):
Classes for adding interactive charting capabilities to Pivot applications.
-* Tools (pivot-tools-1.4.jar):
+* Tools (pivot-tools-1.5.jar):
Development tools and utility applications.
To begin developing with Pivot, simply include the necessary libraries on your
@@ -73,7 +73,7 @@ Dependencies
http://code.google.com/p/pivot-jfree/
- Version 1.4 of this provider is compatible with Pivot 1.4. Please note that
+ Version 1.5 of this provider is compatible with Pivot 1.5. Please note that
this provider has a dependency on JFreeChart, which is licensed under LGPL.
* Scripting support requires a compatible script engine. See
@@ -88,4 +88,4 @@ Documentation
Pivot home page: http://pivot.apache.org/
Demos: http://pivot.apache.org/demos/
Tutorials: http://pivot.apache.org/tutorials/
-Javadoc: http://pivot.apache.org/1.4/docs/api/
+Javadoc: http://pivot.apache.org/1.5/docs/api/
View
273 RELEASE-NOTES
@@ -15,182 +15,97 @@
limitations under the License.
================================================================================
-Release notes for Pivot 1.4:
-
-
-New Features
-------------
-
-- Complete TextArea (PIVOT-16)
-
-- Add orientation to Meter component (PIVOT-26)
-
-- Add orientation to Slider component (PIVOT-27)
-
-- Add support for Meter#text property in TerraMeterSkin (PIVOT-33)
-
-- implement a color chooser widget (PIVOT-77)
-
-- baseline alignment in layout (PIVOT-99)
-
-- Add a GridPane container (PIVOT-227)
-
-- Double-clicking on a table view header's column-resize area should size the
- column to fit (PIVOT-248)
-
-- Add support for declaring event handlers in WTKX attributes (PIVOT-274)
-
-- DesktopApplicationContext should remember its screen location and size
- (PIVOT-289)
-
-- Add hit detection to drawing primitives (PIVOT-295)
-
-- Make component editors fire events (PIVOT-299)
-
-- Add DisabledCheckmarkFilter to TreeView and ListView (PIVOT-303)
-
-- Add an "automationID" property to Component (PIVOT-307)
-
-- Add support for OS-specific keyboard modifiers and menu separators (PIVOT-309)
-
-- Addition of minimum and maximum width constraint for TableView columns.
- (PIVOT-314)
-
-- Add a "variableRowHeight" style to TerraTableViewSkin (PIVOT-320)
-
-- Add a hideDisabledFiles:boolean style to TerraFileBrowserSkin &
- TerraFileBrowserSheetSkin (PIVOT-321)
-
-- Add a org.apache.pivot.util.Time class (PIVOT-328)
-
-- Support stroke property in Text shape (PIVOT-334)
-
-- Add XPath support to XMLSerializer (PIVOT-341)
-
-- Add native XML support (PIVOT-358)
-
-- Add "showEmptyBranchControls" style to TerraTreeViewSkin (PIVOT-370)
-
-
-Improvements
-------------
-
-- Optimize LabelSkin#paint(Graphics2D) (PIVOT-103)
-
-- pivot/wtk/ApplicationContext.java:1201 ApplicationContext.resourceCache is or
- uses a map or set of URLs, which can be a performance hog (PIVOT-132)
-
-- Add bounds checks on skin styles (PIVOT-173)
-
-- Revisit TextInput/TerraTextInputSkin implementation (PIVOT-233)
-
-- Add resizing support to TerraSheetSkin (PIVOT-234)
-
-- Complete tutorial documentation (PIVOT-235)
-
-- SplitPane's resize weight should be configurable (PIVOT-236)
-
-- Create new ButtonGroup class that implements
- org.apache.pivot.collections.Group and Iterable<Button> (PIVOT-292)
-
-- Rename MenuPopup#isAutoClose() to isContextMenu() (PIVOT-294)
-
-- Determine a Drawing's bounds from its Canvas rather than explicit width and
- height properties (PIVOT-296)
-
-- Refine TableView sort API (PIVOT-300)
-
-- Add a "variableItemHeight" style to TerraListViewSkin (PIVOT-301)
-
-- Renderers should be passed index/path (PIVOT-305)
-
-- QueryServlet.setSerializerClass is not very extensible (PIVOT-308)
-
-- Make CalendarDate a struct-like class (PIVOT-310)
-
-- Add new font setters to text-based skin classes that allow a caller to
- customize the theme font (PIVOT-312)
-
-- FileBrowser sorting improvements (PIVOT-316)
-
-- WTKXSerializer get method enhancement (PIVOT-324)
-
-- Allow to use SHIFT+END/HOME to select text in TextInput (PIVOT-325)
-
-- Make ImageView bindable (PIVOT-326)
-
-- Allow ImageView to load images in the background (PIVOT-327)
-
-- Maven POMs for Pivot (submission) (PIVOT-333)
-
-- Update skins to respect height argument in getBaseline() (PIVOT-340)
-
-
-Bug Fixes
----------
-
-- Compile warnings [rawtypes] when built with JDK1.7 (PIVOT-249)
-
-- ScrollPane optimization can fail for nested scroll panes (PIVOT-254)
-
-- Column header in Stock Tracker demo shows trailing vertical grid line
- (PIVOT-281)
-
-- Highlight state not cleared properly in nested context menus (PIVOT-290)
-
-- Table re-sorts itself incorrectly in the stock tracker tutorial (PIVOT-291)
-
-- Window.open(owner) is prone to memory leak (PIVOT-297)
-
-- Off-by-1 layout error in TerraAccordionSkin (PIVOT-298)
-
-- CSVSerializer doesn't handle special characters correctly (PIVOT-302)
-
-- Exception in Mouse.release when released outside the display host's bounds
- (PIVOT-311)
-
-- Terra's default font cannot display all UTF-8 characters (PIVOT-315)
-
-- IllegalArgumentException causes user to be stuck in full screen mode
- (PIVOT-319)
-
-- PushButton pressed state is not shown for focused buttons in layered windows
- (PIVOT-323)
-
-- Native file drag & drop doesn't work in Linux (PIVOT-329)
-
-- Errors in FloatValidator (PIVOT-335)
-
-- Corner case bug in TextInput.maximumLength restriction (PIVOT-336)
-
-- FileBrowser[Sheet] doesn't allow navigation to different logical drives in
- Windows (PIVOT-337)
-
-- TerraPushButtonSkin baseline calculation fails when button is given more than
- its preferred height (PIVOT-338)
-
-- ImageViewSkin fill/preserveAspectRatio can yield clipping (PIVOT-339)
-
-- Cutoff text field not accepting focus (TablePane Demo) (PIVOT-349)
-
-- Bug in Sequence.Tree.pathOf (PIVOT-351)
-
-- Drag&Drop in Kitchen Sink Allows One Image to Overwrite Another (PIVOT-362)
-
-- Stock Tracker Demo: Inconsistent Selection Behavior when Adding New Ticket
- Symbol (PIVOT-363)
-
-- Exception in StockTracker (PIVOT-364)
-
-- StockTracker Stuck Displaying Blank (PIVOT-365)
-
-- XMLViewer Doesn't Accept Tag Names with Underscores (PIVOT-366)
-
-
-Tasks Accomplished
-------------------
-
-- Add missing resources in generated jar files, for compatibility with Apache
- Maven Repository (PIVOT-260)
-
-- Add Web Start file for some Demos (PIVOT-261)
+Release Notes for Pivot 1.5:
+
+** New Feature
+ * [PIVOT-93] - Create a pivot.sql.ResultList class
+ * [PIVOT-330] - Add a SuggestionPopup class (API change)
+ * [PIVOT-377] - Provide access to the window in popup button components
+ * [PIVOT-382] - Add Pom files for other Pivot jars
+ * [PIVOT-395] - Provide a means for decoupled, intra-application message passing
+ * [PIVOT-409] - Allow users to navigate list view content via keyboard (API change)
+ * [PIVOT-410] - Allow users to navigate menu content via keyboard
+ * [PIVOT-419] - Add Ability to Add tooltipText for Tabs in a TabPane.
+ * [PIVOT-421] - Add a FileSerializer class
+ * [PIVOT-425] - Make data binding more robust
+ * [PIVOT-426] - Add support for controlling bind direction
+ * [PIVOT-460] - Addtional maximized argument for desktop applications
+ * [PIVOT-479] - TextInput: paint prompt if focused and input is blank
+
+** Improvement
+ * [PIVOT-35] - Replace Dispatcher with ExecutorService (API change)
+ * [PIVOT-371] - Support word navigation in TextInput and TextArea
+ * [PIVOT-381] - Handle Home and End keys in TextArea, as in TextInput
+ * [PIVOT-383] - Jars for Sources in Maven Repository
+ * [PIVOT-386] - Improve user experience in TerraFormSkin (API change)
+ * [PIVOT-394] - Allow Tooltips to contain arbitrary content (API change)
+ * [PIVOT-396] - Add a Resources argument to org.apache.pivot.wtkx.Bindable#initialize() (API
+ change)
+ * [PIVOT-402] - Update QueryServlet API for consistency with client-side Query API (API change)
+ * [PIVOT-404] - Protected Component attributes methods doesn't work for custom components
+ * [PIVOT-407] - Make FileBrowserSheet WTKX-compatible. (API addition)
+ * [PIVOT-408] - Make Dialog more WTKX-friendly (API change/addition)
+ * [PIVOT-415] - Make Alert and Prompt properties mutable (API addition)
+ * [PIVOT-427] - Rename Direction enum to FocusTraversalDirection (API change)
+ * [PIVOT-428] - Add "inline" attribute to <wtkx:include> element (API change)
+ * [PIVOT-429] - Change return type of PutQuery to Boolean (API change)
+ * [PIVOT-436] - Window.setTitle() and Window.setIcon() do not change the equivalent Frame
+ properties once the Window has been opened. (DesktopApplicationContext)
+ * [PIVOT-439] - Remove the TablePane.Row.setVisible() method (API change)
+ * [PIVOT-442] - Split JSON path methods into dedicated JSON class; move to
+ org.apache.pivot.json (API change)
+ * [PIVOT-443] - Move "strictValidation" style from TerraTextInputSkin to intrinsic
+ property (API change)
+ * [PIVOT-449] - Eliminate WTKXSerializer.reset() (API change)
+ * [PIVOT-450] - Rename TextInput and TextArea insertText() to insert() (API change)
+ * [PIVOT-456] - Enhance Messages (and make them not blocking) when wrong Startup Properties are
+ given to DesktopApplicationContext
+ * [PIVOT-462] - Eliminate Container "contextKey" property (API change)
+ * [PIVOT-464] - Add a BeanMap (or BeanAdapter) class (API change)
+ * [PIVOT-465] - Eliminate MapList class (API change)
+ * [PIVOT-466] - Use Object in Component#load() and Component#store() instead of
+ Dictionary (API change)
+ * [PIVOT-467] - Allow JSONSerializer#writeObject() to write Java bean values
+ * [PIVOT-471] - Make TableView.getSelectedRanges() iterable (API change)
+ * [PIVOT-472] - Rename alternateRowColor style to alternateRowBackgroundColor (API change)
+ * [PIVOT-474] - Ensure that selection is visible in ListView, TableView, etc.
+ * [PIVOT-475] - Move TerraListViewSkin "listSize" style to intrinsic ListButton property (API
+ change)
+ * [PIVOT-480] - Add "year" and "month" properties to CalendarButton (API addition)
+ * [PIVOT-483] - better exception reporting for BeanAdapter
+ * [PIVOT-493] - Add color name from java.awt.Color in styles's attribute
+ * [PIVOT-495] - Minor UE enhancements
+ * [PIVOT-504] - Move XML path accessor methods to XML class (API change)
+
+** Bug
+ * [PIVOT-350] - Dollar signs in table row editor demo don't appear correctly
+ * [PIVOT-373] - Exception in Vertical Sliders
+ * [PIVOT-374] - Sheets may be misaligned when first opened
+ * [PIVOT-375] - Alert not showing active state correctly
+ * [PIVOT-376] - Alerts briefly show at wrong location when opened
+ * [PIVOT-379] - Strange Chars in Localization Tutorial
+ * [PIVOT-388] - Wrong parameter name in the Hello World tutorial
+ * [PIVOT-393] - Certain UI components do not properly respect system text anti-aliasing hints
+ * [PIVOT-413] - Change default encoding for Resources to UTF-8
+ * [PIVOT-437] - Build doesn't work with Ant 1.8.0
+ * [PIVOT-417] - TerraTreeViewSkin throws exception when its container's width is so narrow that
+ the node is mostly clipped.
+ * [PIVOT-438] - TablePane paints grid lines for hidden rows
+ * [PIVOT-446] - Dialog does not become active when clicked
+ * [PIVOT-447] - TextInput Component's selection methods throw NPE when textNode property is null
+ * [PIVOT-461] - Sine doesn't implement Easing
+ * [PIVOT-469] - TableView multi-select: ctrl-clicking doesn't repaint correctly
+ * [PIVOT-476] - Bug in equals method in ArrayList and LinkedList
+ * [PIVOT-484] - ArrayList.ItemIterator.remove() advances the iterator
+ * [PIVOT-485] - TextArea wrapText=true computes wrong preferredHeight
+ * [PIVOT-486] - TableView.setSort(String) doesn't work
+ * [PIVOT-489] - Component Explorer - Problem in WTKX Source
+ * [PIVOT-496] - TerraTheme.darken(Color) doesn't preserve alpha channel
+ * [PIVOT-501] - org.apache.pivot.tutorials.explorer.ComponentExplorer fails to handle exception
+ thrown when 'exploring' ScrollBar
+ * [PIVOT-503] - Using ClearType, bold text in Pivot 1.5 looks very bad
+
+** Task
+ * [PIVOT-432] - Add Yahoo! suggest demo to site
+ * [PIVOT-444] - Rename org.apache.pivot.wtk.text.validation to
+ org.apache.pivot.wtk.validation (API change)
View
10 build.xml
@@ -618,23 +618,23 @@ limitations under the License.
</artifact:install>
<artifact:install file="lib/${jar.core}">
<artifact:pom file="core/pom.xml"/>
- <attach file="lib/${jar.core.sources}" classifier="sources" />
+ <attach file="lib/${jar.core.sources}" classifier="sources" />
</artifact:install>
<artifact:install file="lib/${jar.web}">
<artifact:pom file="web/pom.xml"/>
- <attach file="lib/${jar.web.sources}" classifier="sources" />
+ <attach file="lib/${jar.web.sources}" classifier="sources" />
</artifact:install>
<artifact:install file="lib/${jar.wtk}">
<artifact:pom file="wtk/pom.xml"/>
- <attach file="lib/${jar.wtk.sources}" classifier="sources" />
+ <attach file="lib/${jar.wtk.sources}" classifier="sources" />
</artifact:install>
<artifact:install file="lib/${jar.wtk-terra}">
<artifact:pom file="wtk-terra/pom.xml"/>
- <attach file="lib/${jar.wtk-terra.sources}" classifier="sources" />
+ <attach file="lib/${jar.wtk-terra.sources}" classifier="sources" />
</artifact:install>
<artifact:install file="lib/${jar.charts}">
<artifact:pom file="charts/pom.xml"/>
- <attach file="lib/${jar.charts.sources}" classifier="sources" />
+ <attach file="lib/${jar.charts.sources}" classifier="sources" />
</artifact:install>
</target>
View
42 core/src/org/apache/pivot/collections/HashMap.java
@@ -427,6 +427,48 @@ public void setComparator(Comparator<K> comparator) {
}
@Override
+ @SuppressWarnings("unchecked")
+ public boolean equals(Object o) {
+ boolean equals = false;
+
+ if (this == o) {
+ equals = true;
+ } else if (o instanceof Map<?, ?>) {
+ Map<K, V> map = (Map<K, V>)o;
+
+ if (count == map.getCount()) {
+ for (K key : this) {
+ V value = get(key);
+
+ if (value == null) {
+ equals = (map.containsKey(key)
+ && map.get(key) == null);
+ } else {
+ equals = value.equals(map.get(key));
+ }
+
+ if (!equals) {
+ break;
+ }
+ }
+ }
+ }
+
+ return equals;
+ }
+
+ @Override
+ public int hashCode() {
+ int hashCode = 0;
+
+ for (K key : this) {
+ hashCode += key.hashCode();
+ }
+
+ return hashCode;
+ }
+
+ @Override
public String toString() {
StringBuilder sb = new StringBuilder();
View
36 core/src/org/apache/pivot/collections/HashSet.java
@@ -187,6 +187,42 @@ public void setComparator(Comparator<E> comparator) {
}
@Override
+ @SuppressWarnings("unchecked")
+ public boolean equals(Object o) {
+ boolean equals = false;
+
+ if (this == o) {
+ equals = true;
+ } else if (o instanceof Set<?>) {
+ Set<E> set = (Set<E>)o;
+
+ if (getCount() == set.getCount()) {
+ for (E element : this) {
+ equals = set.contains(element);
+
+ if (!equals) {
+ break;
+ }
+ }
+
+ }
+ }
+
+ return equals;
+ }
+
+ @Override
+ public int hashCode() {
+ int hashCode = 0;
+
+ for (E element : this) {
+ hashCode += element.hashCode();
+ }
+
+ return hashCode;
+ }
+
+ @Override
public String toString() {
StringBuilder sb = new StringBuilder();
View
90 core/src/org/apache/pivot/xml/Element.java
@@ -128,6 +128,51 @@ public void setValue(String value) {
}
}
}
+
+ @Override
+ public boolean equals(Object o) {
+ boolean equals = false;
+
+ if (this == o) {
+ equals = true;
+ } else if (o instanceof Attribute) {
+ Attribute attribute = (Attribute)o;
+ if (namespacePrefix == null) {
+ equals = (attribute.namespacePrefix == null);
+ } else {
+ equals = (namespacePrefix.equals(attribute.namespacePrefix));
+ }
+
+ equals &= (localName.equals(attribute.localName)
+ && value.equals(attribute.value));
+ }
+
+ return equals;
+ }
+
+ @Override
+ public int hashCode() {
+ int hashCode = 0;
+ if (namespacePrefix != null) {
+ hashCode += namespacePrefix.hashCode();
+ }
+
+ hashCode += localName.hashCode() + value.hashCode();
+
+ return hashCode;
+ }
+
+ @Override
+ public String toString() {
+ String string = "";
+ if (namespacePrefix != null) {
+ string += namespacePrefix + ":";
+ }
+
+ string += localName + "=\"" + value + "\"";
+
+ return string;
+ }
}
/**
@@ -916,4 +961,49 @@ private static void validateName(String namespacePrefix, String localName) {
}
}
}
+
+ @Override
+ public boolean equals(Object o) {
+ boolean equals = false;
+
+ if (this == o) {
+ equals = true;
+ } else if (o instanceof Element) {
+ Element element = (Element)o;
+ if (namespacePrefix == null) {
+ equals = (element.namespacePrefix == null);
+ } else {
+ equals = (namespacePrefix.equals(element.namespacePrefix));
+ }
+
+ equals &= (attributes.equals(element.attributes)
+ && nodes.equals(element.nodes));
+ }
+
+ return equals;
+ }
+
+ @Override
+ public int hashCode() {
+ int hashCode = 0;
+ if (namespacePrefix != null) {
+ hashCode += namespacePrefix.hashCode();
+ }
+
+ hashCode += localName.hashCode() + attributes.hashCode() + nodes.hashCode();
+
+ return hashCode;
+ }
+
+ @Override
+ public String toString() {
+ String string = "<";
+ if (namespacePrefix != null) {
+ string += namespacePrefix + ":";
+ }
+
+ string += localName + ">";
+
+ return string;
+ }
}
View
24 core/src/org/apache/pivot/xml/TextNode.java
@@ -33,4 +33,28 @@ public TextNode(String text) {
public String getText() {
return text;
}
+
+ @Override
+ public boolean equals(Object o) {
+ boolean equals = false;
+
+ if (this == o) {
+ equals = true;
+ } else if (o instanceof TextNode) {
+ TextNode textNode = (TextNode)o;
+ equals = (text.equals(textNode.text));
+ }
+
+ return equals;
+ }
+
+ @Override
+ public int hashCode() {
+ return text.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return text;
+ }
}
View
157 core/src/org/apache/pivot/xml/XML.java
@@ -0,0 +1,157 @@
+/*
+ * 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.collections.ArrayList;
+import org.apache.pivot.collections.List;
+
+/**
+ * Contains utility methods for working with XML structures.
+ */
+public class XML {
+ /**
+ * Returns the element matching a given path.
+ *
+ * @param root
+ * The element from which to begin the search.
+ *
+ * @param path
+ * A path of the form:
+ * <pre>
+ * tag[n]/tag[n]/...
+ * </pre>
+ * The bracketed index values are optional and refer to the <i>n</i>th
+ * occurrence of the given tag name within its parent element. If
+ * omitted, the path refers to the first occurrence of the named
+ * element (i.e. the element at index 0).
+ *
+ * @return
+ * The matching element, or {@code null} if no such element exists.
+ */
+ public static Element getElement(Element root, String path) {
+ if (root == null) {
+ throw new IllegalArgumentException("root is null.");
+ }
+
+ if (path == null) {
+ throw new IllegalArgumentException("path is null.");
+ }
+
+ if (path.length() == 0) {
+ throw new IllegalArgumentException("path is empty.");
+ }
+
+ ArrayList<String> pathComponents = new ArrayList<String>(path.split("/"));
+ Element current = root;
+
+ for (int i = 0, n = pathComponents.getLength(); i < n; i++) {
+ String pathComponent = pathComponents.get(i);
+
+ String tagName;
+ int index;
+ int leadingBracketIndex = pathComponent.indexOf('[');
+ if (leadingBracketIndex == -1) {
+ tagName = pathComponent;
+ index = 0;
+ } else {
+ tagName = pathComponent.substring(0, leadingBracketIndex);
+
+ int trailingBracketIndex = pathComponent.lastIndexOf(']');
+ if (trailingBracketIndex == -1) {
+ throw new IllegalArgumentException("Unterminated index identifier.");
+ }
+
+ index = Integer.parseInt(pathComponent.substring(leadingBracketIndex + 1,
+ trailingBracketIndex));
+ }
+
+
+ int j = 0;
+ int k = 0;
+ for (Node node : current) {
+ if (node instanceof Element) {
+ Element element = (Element)node;
+
+ if (element.getName().equals(tagName)) {
+ if (k == index) {
+ break;
+ }
+
+ k++;
+ }
+ }
+
+ j++;
+ }
+
+ if (j < current.getLength()) {
+ current = (Element)current.get(j);
+ } else {
+ current = null;
+ break;
+ }
+ }
+
+ return current;
+ }
+
+ /**
+ * Returns the sub-elements of a descendant of {@code root} whose tag names
+ * match the given name.
+ *
+ * @param root
+ * The element from which to begin the search.
+ *
+ * @param path
+ * The path to the descendant, relative to {@code root}.
+ *
+ * @param name
+ * The tag name to match.
+ *
+ * @return
+ * The matching elements, or {@code null} if no such descendant exists.
+ *
+ * @see #getElement(Element, String)
+ * @see Element#getElements(String)
+ */
+ public static List<Element> getElements(Element root, String path, String name) {
+ Element element = getElement(root, path);
+ return (element == null) ? null : element.getElements(name);
+ }
+
+ /**
+ * Returns the text content of a descendant of {@code root}.
+ *
+ * @param root
+ * The element from which to begin the search.
+ *
+ * @param path
+ * The path to the descendant, relative to {@code root}.
+ *
+ * @return
+ * The text of the descedant, or {@code null} if no such descendant
+ * exists.
+ *
+ * @see #getElement(Element, String)
+ * @see Element#getText()
+ */
+ public static String getText(Element root, String path) {
+ Element element = getElement(root, path);
+ return (element == null) ? null : element.getText();
+ }
+
+}
View
133 core/src/org/apache/pivot/xml/XMLSerializer.java
@@ -34,8 +34,6 @@
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
-import org.apache.pivot.collections.ArrayList;
-import org.apache.pivot.collections.List;
import org.apache.pivot.serialization.SerializationException;
import org.apache.pivot.serialization.Serializer;
@@ -287,135 +285,4 @@ private void writeTextNode(TextNode textNode, XMLStreamWriter xmlStreamWriter)
public String getMIMEType(Element object) {
return MIME_TYPE;
}
-
- /**
- * Returns the element matching a given path.
- *
- * @param root
- * The element from which to begin the search.
- *
- * @param path
- * A path of the form:
- * <pre>
- * tag[n]/tag[n]/...
- * </pre>
- * The bracketed index values are optional and refer to the <i>n</i>th
- * occurrence of the given tag name within its parent element. If
- * omitted, the path refers to the first occurrence of the named
- * element (i.e. the element at index 0).
- *
- * @return
- * The matching element, or {@code null} if no such element exists.
- */
- public static Element getElement(Element root, String path) {
- if (root == null) {
- throw new IllegalArgumentException("root is null.");
- }
-
- if (path == null) {
- throw new IllegalArgumentException("path is null.");
- }
-
- if (path.length() == 0) {
- throw new IllegalArgumentException("path is empty.");
- }
-
- ArrayList<String> pathComponents = new ArrayList<String>(path.split("/"));
- Element current = root;
-
- for (int i = 0, n = pathComponents.getLength(); i < n; i++) {
- String pathComponent = pathComponents.get(i);
-
- String tagName;
- int index;
- int leadingBracketIndex = pathComponent.indexOf('[');
- if (leadingBracketIndex == -1) {
- tagName = pathComponent;
- index = 0;
- } else {
- tagName = pathComponent.substring(0, leadingBracketIndex);
-
- int trailingBracketIndex = pathComponent.lastIndexOf(']');
- if (trailingBracketIndex == -1) {
- throw new IllegalArgumentException("Unterminated index identifier.");
- }
-
- index = Integer.parseInt(pathComponent.substring(leadingBracketIndex + 1,
- trailingBracketIndex));
- }
-
-
- int j = 0;
- int k = 0;
- for (Node node : current) {
- if (node instanceof Element) {
- Element element = (Element)node;
-
- if (element.getName().equals(tagName)) {
- if (k == index) {
- break;
- }
-
- k++;
- }
- }
-
- j++;
- }
-
- if (j < current.getLength()) {
- current = (Element)current.get(j);
- } else {
- current = null;
- break;
- }
- }
-
- return current;
- }
-
- /**
- * Returns the sub-elements of a descendant of {@code root} whose tag names
- * match the given name.
- *
- * @param root
- * The element from which to begin the search.
- *
- * @param path
- * The path to the descendant, relative to {@code root}.
- *
- * @param name
- * The tag name to match.
- *
- * @return
- * The matching elements, or {@code null} if no such descendant exists.
- *
- * @see #getElement(Element, String)
- * @see Element#getElements(String)
- */
- public static List<Element> getElements(Element root, String path, String name) {
- Element element = getElement(root, path);
- return (element == null) ? null : element.getElements(name);
- }
-
- /**
- * Returns the text content of a descendant of {@code root}.
- *
- * @param root
- * The element from which to begin the search.
- *
- * @param path
- * The path to the descendant, relative to {@code root}.
- *
- * @return
- * The text of the descedant, or {@code null} if no such descendant
- * exists.
- *
- * @see #getElement(Element, String)
- * @see Element#getText()
- */
- public static String getText(Element root, String path) {
- Element element = getElement(root, path);
- return (element == null) ? null : element.getText();
- }
}
View
33 core/test/org/apache/pivot/collections/test/HashMapTest.java
@@ -17,7 +17,7 @@
package org.apache.pivot.collections.test;
- import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -197,4 +197,35 @@ public void iteratorTest() {
System.out.println(key);
}
}
+
+ @Test
+ public void equalsTest() {
+ HashMap<String, String> map1 = new HashMap<String, String>();
+ map1.put("a", "one");
+ map1.put("b", "two");
+ map1.put("c", "three");
+
+ HashMap<String, String> map2 = new HashMap<String, String>();
+ map2.put("a", "one");
+ map2.put("b", "two");
+ map2.put("c", "three");
+
+ // Same
+ assertTrue(map1.equals(map2));
+
+ // Different values
+ map2.put("c", "four");
+ assertFalse(map1.equals(map2));
+
+ map1.put("c", null);
+ assertFalse(map1.equals(map2));
+
+ // Null comparison
+ map2.put("c", null);
+ assertTrue(map1.equals(map2));
+
+ // Different lengths
+ map2.put("d", "four");
+ assertFalse(map1.equals(map2));
+ }
}
View
25 core/test/org/apache/pivot/collections/test/HashSetTest.java
@@ -76,4 +76,29 @@ public void basicTest() {
}
assertEquals(0, set.getCount());
}
+
+ @Test
+ public void equalsTest() {
+ HashSet<String> set1 = new HashSet<String>();
+ set1.add("one");
+ set1.add("two");
+ set1.add("three");
+
+ HashSet<String> set2 = new HashSet<String>();
+ set2.add("one");
+ set2.add("two");
+ set2.add("three");
+
+ // Same
+ assertTrue(set1.equals(set2));
+
+ // Different values
+ set2.remove("three");
+ set2.add("four");
+ assertFalse(set1.equals(set2));
+
+ // Different lengths
+ set2.add("three");
+ assertFalse(set1.equals(set2));
+ }
}
View
21 ...erialization/test/JSONSerializerTest.java → ...e/pivot/json/test/JSONSerializerTest.java
@@ -14,11 +14,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.pivot.serialization.test;
+package org.apache.pivot.json.test;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
import org.apache.pivot.collections.List;
+import org.apache.pivot.json.JSON;
import org.apache.pivot.json.JSONSerializer;
import org.apache.pivot.serialization.SerializationException;
import org.junit.Test;
@@ -45,4 +50,18 @@ public void testInvalidNumbers() {
JSONSerializer.toString(Double.NEGATIVE_INFINITY);
JSONSerializer.toString(Double.POSITIVE_INFINITY);
}
+
+ @Test
+ public void testEquals() throws IOException, SerializationException {
+ JSONSerializer jsonSerializer = new JSONSerializer();
+ Object o1 = jsonSerializer.readObject(getClass().getResourceAsStream("sample.json"));
+ Object o2 = jsonSerializer.readObject(getClass().getResourceAsStream("sample.json"));
+
+ assertTrue(o1.equals(o2));
+
+ List<?> d = JSON.getList(o1, "d");
+ d.remove(0, 1);
+
+ assertFalse(o1.equals(o2));
+ }
}
View
24 core/test/org/apache/pivot/json/test/sample.json
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+ { a: 100,
+ b: "Hello",
+ c: false,
+ d: ["1", "2", "3"],
+ e: {f: [4, 5, 6]},
+ g: [{h:7, i:8, j:9}]
+ }
View
51 core/test/org/apache/pivot/xml/test/XMLSerializerTest.java
@@ -21,11 +21,14 @@
import org.apache.pivot.collections.List;
import org.apache.pivot.serialization.SerializationException;
import org.apache.pivot.xml.Element;
+import org.apache.pivot.xml.XML;
import org.apache.pivot.xml.XMLSerializer;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
public class XMLSerializerTest {
@Test
@@ -36,48 +39,62 @@ public void basicTest() throws IOException, SerializationException {
assertEquals(root.getName(), "root");
- Element a = XMLSerializer.getElement(root, "a");
+ Element a = XML.getElement(root, "a");
assertEquals(a.getName(), "a");
assertEquals(a.get("id"), "x");
- Element b = XMLSerializer.getElement(root, "a/b");
+ Element b = XML.getElement(root, "a/b");
assertEquals(b.getName(), "b");
assertEquals(b.get("id"), "y");
- b = XMLSerializer.getElement(a, "b");
+ b = XML.getElement(a, "b");
assertEquals(b.getName(), "b");
assertEquals(b.get("id"), "y");
- List<Element> cs = XMLSerializer.getElements(root, "a/b", "c");
+ List<Element> cs = XML.getElements(root, "a/b", "c");
assertEquals(cs.getLength(), 1);
- List<Element> fs = XMLSerializer.getElements(root, "d/e", "f");
+ List<Element> fs = XML.getElements(root, "d/e", "f");
assertEquals(fs.getLength(), 4);
- Element e = XMLSerializer.getElement(root, "d/e");
- Element f = XMLSerializer.getElement(e, "f");
+ Element e = XML.getElement(root, "d/e");
+ Element f = XML.getElement(e, "f");
assertEquals(f.getName(), "f");
- Element g = XMLSerializer.getElement(e, "g");
+ Element g = XML.getElement(e, "g");
assertEquals(g.getName(), "g");
- String ft = XMLSerializer.getText(root, "d/e/f");
+ String ft = XML.getText(root, "d/e/f");
assertEquals(ft, "1");
- String gt = XMLSerializer.getText(root, "d/e/g");
+ String gt = XML.getText(root, "d/e/g");
assertEquals(gt, "4");
- assertNull(XMLSerializer.getElement(root, "a/b/n"));
- assertNull(XMLSerializer.getText(root, "a/b/n"));
+ assertNull(XML.getElement(root, "a/b/n"));
+ assertNull(XML.getText(root, "a/b/n"));
- assertEquals(XMLSerializer.getElements(root, "a/b", "n").getLength(), 0);
+ assertEquals(XML.getElements(root, "a/b", "n").getLength(), 0);
- assertEquals(XMLSerializer.getText(root, "d/foo:h"), "Hello");
+ assertEquals(XML.getText(root, "d/foo:h"), "Hello");
- List<Element> is = XMLSerializer.getElements(e, "is", "i");
+ List<Element> is = XML.getElements(e, "is", "i");
assertEquals(is.getLength(), 3);
- assertEquals(XMLSerializer.getText(root, "d[0]/e[0]/f[2]"), "3");
- assertEquals(XMLSerializer.getText(root, "d[0]/e[1]"), null);
+ assertEquals(XML.getText(root, "d[0]/e[0]/f[2]"), "3");
+ assertEquals(XML.getText(root, "d[0]/e[1]"), null);
+ }
+
+ @Test
+ public void equalsTest() throws IOException, SerializationException {
+ XMLSerializer xmlSerializer = new XMLSerializer();
+ Element root1 = xmlSerializer.readObject(getClass().getResourceAsStream("sample.xml"));
+ Element root2 = xmlSerializer.readObject(getClass().getResourceAsStream("sample.xml"));
+
+ assertTrue(root1.equals(root2));
+
+ Element a = XML.getElement(root2, "a");
+ a.getAttributes().remove(0, 1);
+
+ assertFalse(root1.equals(root2));
}
}
View
5 demos/src/org/apache/pivot/demos/rss/RSSFeedDemo.java
@@ -39,6 +39,7 @@
import org.apache.pivot.wtk.Window;
import org.apache.pivot.wtkx.WTKXSerializer;
import org.apache.pivot.xml.Element;
+import org.apache.pivot.xml.XML;
import org.apache.pivot.xml.XMLSerializer;
public class RSSFeedDemo implements Application {
@@ -67,7 +68,7 @@ public boolean mouseClick(Component component, Mouse.Button button, int x, int y
&& feedListView.getItemAt(y) == index) {
Element itemElement = (Element)feedListView.getListData().get(index);
- String link = XMLSerializer.getText(itemElement, "link");
+ String link = XML.getText(itemElement, "link");
Desktop desktop = Desktop.getDesktop();
try {
@@ -93,7 +94,7 @@ public boolean mouseClick(Component component, Mouse.Button button, int x, int y
@Override
public void taskExecuted(Task<Object> task) {
Element root = (Element)task.getResult();
- feedListView.setListData(XMLSerializer.getElements(root, "channel", "item"));
+ feedListView.setListData(XML.getElements(root, "channel", "item"));
cardPane.setSelectedIndex(1);
}
View
8 demos/src/org/apache/pivot/demos/rss/RSSItemRenderer.java
@@ -27,7 +27,7 @@
import org.apache.pivot.wtk.Orientation;
import org.apache.pivot.xml.Element;
import org.apache.pivot.xml.TextNode;
-import org.apache.pivot.xml.XMLSerializer;
+import org.apache.pivot.xml.XML;
public class RSSItemRenderer extends BoxPane implements ListView.ItemRenderer {
private Label titleLabel = new Label();
@@ -65,7 +65,7 @@ public void render(Object item, int index, ListView listView, boolean selected,
if (item != null) {
Element itemElement = (Element)item;
- String title = XMLSerializer.getText(itemElement, "title");
+ String title = XML.getText(itemElement, "title");
titleLabel.setText(title);
String categories = "Categories:";
@@ -84,7 +84,7 @@ public void render(Object item, int index, ListView listView, boolean selected,
categoriesLabel.setText(categories);
- String submitter = XMLSerializer.getText(itemElement, "dz:submitter/dz:username");
+ String submitter = XML.getText(itemElement, "dz:submitter/dz:username");
submitterLabel.setText("Submitter: " + submitter);
}
@@ -116,6 +116,6 @@ public void render(Object item, int index, ListView listView, boolean selected,
@Override
public String toString(Object item) {
- return XMLSerializer.getText((Element)item, "title");
+ return XML.getText((Element)item, "title");
}
}
View
13 demos/xsl/index.xsl
@@ -52,16 +52,9 @@ limitations under the License.
<hr/>
</xsl:if>
- <h3><xsl:value-of select="normalize-space($document/properties/title)"/></h3>
- <p>
- <a href="{$id}.html">Applet</a>
-
- <!-- JNLP translation must ignore the head, so if one exists, we skip JNLP link -->
- <xsl:if test="not($document/head)">
- <xsl:text> | </xsl:text>
- <a href="{$id}.jnlp">Web Start</a>
- </xsl:if>
- </p>
+ <h3>
+ <a href="{$id}.html"><xsl:value-of select="normalize-space($document/properties/title)"/></a>
+ </h3>
<p>
<xsl:value-of select="normalize-space($document/properties/description)"/>
</p>
View
BIN  etc/pivot.keystore
Binary file not shown
View
16 tests/src/org/apache/pivot/tests/BindableWindow.json
@@ -1,2 +1,18 @@
+/*
+ * 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.
+ */
{ message:"Hello Bindable!"
}
View
16 tutorials/src/org/apache/pivot/tutorials/stocktracker/ValueMapping.java
@@ -1,3 +1,19 @@
+/*
+ * 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.tutorials.stocktracker;
import java.text.DecimalFormat;
View
9 wtk/src/org/apache/pivot/wtk/content/ButtonDataRenderer.java
@@ -105,16 +105,15 @@ public void render(Object data, Button button, boolean highlighted) {
@Override
public String toString(Object data) {
- if (data == null) {
- throw new IllegalArgumentException();
- }
+ String string = null;
- String string;
if (data instanceof ButtonData) {
ButtonData buttonData = (ButtonData)data;
string = buttonData.getText();
} else {
- string = data.toString();
+ if (data != null) {
+ string = data.toString();
+ }
}
return string;
View
9 wtk/src/org/apache/pivot/wtk/content/LinkButtonDataRenderer.java
@@ -111,16 +111,15 @@ public void render(Object data, Button button, boolean highlighted) {
@Override
public String toString(Object data) {
- if (data == null) {
- throw new IllegalArgumentException();
- }
+ String string = null;
- String string;
if (data instanceof ButtonData) {
ButtonData buttonData = (ButtonData)data;
string = buttonData.getText();
} else {
- string = data.toString();
+ if (data != null) {
+ string = data.toString();
+ }
}
return string;
View
9 wtk/src/org/apache/pivot/wtk/content/ListViewItemRenderer.java
@@ -112,16 +112,15 @@ protected void renderStyles(ListView listView, boolean selected,
}
public String toString(Object item) {
- if (item == null) {
- throw new IllegalArgumentException();
- }
+ String string = null;
- String string;
if (item instanceof ListItem) {
ListItem listItem = (ListItem)item;
string = listItem.getText();
} else {
- string = item.toString();
+ if (item != null) {
+ string = item.toString();
+ }
}
return string;
View
9 wtk/src/org/apache/pivot/wtk/content/MenuBarItemDataRenderer.java
@@ -114,16 +114,15 @@ public void render(Object data, Button button, boolean highlighted) {
@Override
public String toString(Object data) {
- if (data == null) {
- throw new IllegalArgumentException();
- }
+ String string = null;
- String string;
if (data instanceof ButtonData) {
ButtonData buttonData = (ButtonData)data;
string = buttonData.getText();
} else {
- string = data.toString();
+ if (data != null) {
+ string = data.toString();
+ }
}
return string;
View
9 wtk/src/org/apache/pivot/wtk/content/MenuItemDataRenderer.java
@@ -145,16 +145,15 @@ public void render(Object data, Button button, boolean highlighted) {
@Override
public String toString(Object data) {
- if (data == null) {
- throw new IllegalArgumentException();
- }
+ String string = null;
- String string;
if (data instanceof ButtonData) {
ButtonData buttonData = (ButtonData)data;
string = buttonData.getText();
} else {
- string = data.toString();
+ if (data != null) {
+ string = data.toString();
+ }
}
return string;
View
6 wtk/src/org/apache/pivot/wtk/content/SpinnerItemRenderer.java
@@ -66,10 +66,6 @@ protected void renderStyles(Spinner spinner) {
}
public String toString(Object item) {
- if (item == null) {
- throw new IllegalArgumentException();
- }
-
- return item.toString();
+ return (item == null) ? null : item.toString();
}
}
View
9 wtk/src/org/apache/pivot/wtk/content/TreeViewNodeRenderer.java
@@ -131,16 +131,15 @@ public void render(Object node, Path path, int rowIndex, TreeView treeView, bool
}
public String toString(Object node) {
- if (node == null) {
- throw new IllegalArgumentException();
- }
+ String string = null;
- String string;
if (node instanceof TreeNode) {
TreeNode treeNode = (TreeNode)node;
string = treeNode.getText();
} else {
- string = node.toString();
+ if (node != null) {
+ string = node.toString();
+ }
}
return string;
Please sign in to comment.
Something went wrong with that request. Please try again.