Author: adubovsky
Date: 2009-03-30 05:59:44 -0400 (Mon, 30 Mar 2009)
New Revision: 13285
Added:
trunk/test-applications/jsp/src/main/java/util/data/Car.java
trunk/test-applications/jsp/src/main/java/util/data/CarProvider.java
trunk/test-applications/jsp/src/main/resources/org/richfaces/renderkit/calendar_en_US.properties
trunk/test-applications/jsp/src/main/resources/util/
trunk/test-applications/jsp/src/main/resources/util/data/
trunk/test-applications/jsp/src/main/resources/util/data/cars.xml
Log:
+ Car class
Added: trunk/test-applications/jsp/src/main/java/util/data/Car.java
===================================================================
--- trunk/test-applications/jsp/src/main/java/util/data/Car.java
(rev 0)
+++ trunk/test-applications/jsp/src/main/java/util/data/Car.java 2009-03-30 09:59:44 UTC
(rev 13285)
@@ -0,0 +1,76 @@
+package util.data;
+
+public class Car {
+
+ private String make;
+
+ private String model;
+
+ private Integer price;
+
+ public Car() {
+ this.make = "";
+ this.model = "";
+ this.price = 0;
+ }
+
+ public Car(String mak, String mod, Integer pr) {
+ this.make = mak;
+ this.model = mod;
+ this.price = pr;
+ }
+
+ public String getMake() {
+ return make;
+ }
+
+ public void setMake(String make) {
+ this.make = make;
+ }
+
+ public String getModel() {
+ return model;
+ }
+
+ public void setModel(String model) {
+ this.model = model;
+ }
+
+ public Integer getPrice() {
+ return price;
+ }
+
+ public void setPrice(Integer price) {
+ this.price = price;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((make == null) ? 0 : make.hashCode());
+ result = prime * result + ((model == null) ? 0 : model.hashCode());
+ result = prime * result + ((price == null) ? 0 : price.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof Car) {
+ Car car = (Car) obj;
+ if (this.make.equals(car.make) && (this.model.equals(car.model))
+ && (this.price.equals(car.price))) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return this.make + ":" + this.model + ":" + this.price;
+ }
+}
\ No newline at end of file
Added: trunk/test-applications/jsp/src/main/java/util/data/CarProvider.java
===================================================================
--- trunk/test-applications/jsp/src/main/java/util/data/CarProvider.java
(rev 0)
+++ trunk/test-applications/jsp/src/main/java/util/data/CarProvider.java 2009-03-30
09:59:44 UTC (rev 13285)
@@ -0,0 +1,111 @@
+package util.data;
+
+import java.util.ArrayList;
+
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.DefaultHandler;
+
+public class CarProvider extends DefaultHandler {
+
+ private ArrayList<Car> allCars = null;
+
+ public CarProvider() {
+ if (allCars == null) {
+ allCars = new ArrayList<Car>();
+ try {
+ SAXParserFactory spf = SAXParserFactory.newInstance();
+ SAXParser sp = spf.newSAXParser();
+ sp.parse(new InputSource(getClass().getResourceAsStream(
+ "cars.xml")), this);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public ArrayList<Car> getAllCars() {
+ return allCars;
+ }
+
+ private String element = "";
+ private String mak = "";
+ private String mod = "";
+ private Integer pr = 0;
+
+ public void startDocument() {
+ System.out.println("*** > Parser starts its work");
+ }
+
+ public void startElement(String namespaceURI, String localName,
+ String rawName, Attributes attrs) {
+ element = rawName;
+
+// System.out.print("<");
+// System.out.print(rawName);
+// if (attrs != null) {
+// int len = attrs.getLength();
+// for (int i = 0; i < len; i++) {
+// System.out.print(" ");
+// System.out.print(attrs.getQName(i));
+// System.out.print("=\"");
+// System.out.print(attrs.getValue(i));
+// System.out.print("\"");
+// }
+// }
+// System.out.print(">");
+ }
+
+ public void characters(char ch[], int start, int length) {
+ String text = new String(ch, start, length);
+// System.out.print(text);
+
+ if (element.equals("make")) {
+ element = "";
+ mak = text;
+ } else if (element.equals("model")) {
+ element = "";
+ mod = text;
+ } else if (element.equals("price")) {
+ try {
+ element = "";
+ Integer p = Integer.parseInt(text);
+ pr = p;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public void endElement(String namespaceURI, String localName, String rawName) {
+// System.out.print("</");
+// System.out.print(rawName);
+// System.out.print(">");
+
+ if (rawName.equals("car")) {
+ allCars.add(new Car(mak, mod, pr));
+ }
+ }
+
+ public void endDocument() {
+ System.out.println("*** > Parser ends its work");
+ }
+
+ public void warning(SAXParseException ex) {
+ System.err.println("[Warning] : " + ex.getMessage());
+ }
+
+ public void error(SAXParseException ex) {
+ System.err.println("[Error] : " + ex.getMessage());
+ }
+
+ public void fatalError(SAXParseException ex) throws SAXException {
+ System.err.println("[Fatal Error] : " + ex.getMessage());
+ throw ex;
+ }
+}
Added:
trunk/test-applications/jsp/src/main/resources/org/richfaces/renderkit/calendar_en_US.properties
===================================================================
---
trunk/test-applications/jsp/src/main/resources/org/richfaces/renderkit/calendar_en_US.properties
(rev 0)
+++
trunk/test-applications/jsp/src/main/resources/org/richfaces/renderkit/calendar_en_US.properties 2009-03-30
09:59:44 UTC (rev 13285)
@@ -0,0 +1,6 @@
+RICH_CALENDAR_APPLY_LABEL=APPLY
+RICH_CALENDAR_TODAY_LABEL=TODAY
+RICH_CALENDAR_CLOSE_LABEL=CLOSE
+RICH_CALENDAR_OK_LABEL=OK
+RICH_CALENDAR_CLEAN_LABEL=CLEAN
+RICH_CALENDAR_CANCEL_LABEL=CANCEL
Added: trunk/test-applications/jsp/src/main/resources/util/data/cars.xml
===================================================================
--- trunk/test-applications/jsp/src/main/resources/util/data/cars.xml
(rev 0)
+++ trunk/test-applications/jsp/src/main/resources/util/data/cars.xml 2009-03-30 09:59:44
UTC (rev 13285)
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<shop>
+ <car>
+ <make>Audi</make>
+ <model>A6</model>
+ <price>20000</price>
+ </car>
+ <car>
+ <make>Audi</make>
+ <model>Q7</model>
+ <price>48500</price>
+ </car>
+ <car>
+ <make>BMW</make>
+ <model>760Li</model>
+ <price>115400</price>
+ </car>
+ <car>
+ <make>Bentley</make>
+ <model>Arnage</model>
+ <price>240000</price>
+ </car>
+ <car>
+ <make>Bugatti</make>
+ <model>Veyron</model>
+ <price>1340000</price>
+ </car>
+ <car>
+ <make>Mercedes-Benz</make>
+ <model>S63 AMG</model>
+ <price>154200</price>
+ </car>
+ <car>
+ <make>Mercedes-Benz</make>
+ <model>SLR</model>
+ <price>854200</price>
+ </car>
+ <car>
+ <make>Mazda</make>
+ <model>6</model>
+ <price>21300</price>
+ </car>
+ <car>
+ <make>Fiat</make>
+ <model>Punto</model>
+ <price>8200</price>
+ </car>
+ <car>
+ <make>Ford</make>
+ <model>GT-40</model>
+ <price>325100</price>
+ </car>
+ <car>
+ <make>Ferrari</make>
+ <model>Enzo</model>
+ <price>950000</price>
+ </car>
+ <car>
+ <make>Jaguar</make>
+ <model>XJ</model>
+ <price>75400</price>
+ </car>
+</shop>
\ No newline at end of file
Show replies by date