http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/xml1b/T6.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/xml1b/T6.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/xml1b/T6.java new file mode 100755 index 0000000..c34126c --- /dev/null +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/xml1b/T6.java @@ -0,0 +1,38 @@ +// *************************************************************************************************************************** +// * 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.juneau.xml.xml1b; + +import org.apache.juneau.annotation.*; +import org.apache.juneau.xml.annotation.*; + +@Xml(prefix="foo",namespace="http://foo") +@Bean(sort=true) +@SuppressWarnings("javadoc") +public class T6 { + + public int f1 = 1; + + @Xml(prefix="bar",namespace="http://bar") public int f2 = 2; + + private int f3 = 3; + public int getF3() { return f3; } + public void setF3(int f3) { this.f3 = f3; } + + private int f4 = 4; + @Xml(prefix="baz",namespace="http://baz") public int getF4() { return f4; } + public void setF4(int f4) { this.f4 = f4; } + + public boolean equals(T6 x) { + return x.f1 == f1 && x.f2 == f2 && x.f3 == f3 && x.f4 == f4; + } +}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/xml1b/T7.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/xml1b/T7.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/xml1b/T7.java new file mode 100755 index 0000000..f2960aa --- /dev/null +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/xml1b/T7.java @@ -0,0 +1,37 @@ +// *************************************************************************************************************************** +// * 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.juneau.xml.xml1b; + +import org.apache.juneau.annotation.*; +import org.apache.juneau.xml.annotation.*; + +@Bean(sort=true) +@SuppressWarnings("javadoc") +public class T7 { + + @BeanProperty(name="g1") public int f1 = 1; + + @Xml(prefix="bar",namespace="http://bar") @BeanProperty(name="g2") public int f2 = 2; + + private int f3 = 3; + @BeanProperty(name="g3") public int getF3() { return f3; } + @BeanProperty(name="g3") public void setF3(int f3) { this.f3 = f3; } + + private int f4 = 4; + @BeanProperty(name="g4") @Xml(prefix="baz",namespace="http://baz") public int getF4() { return f4; } + @BeanProperty(name="g4") public void setF4(int f4) { this.f4 = f4; } + + public boolean equals(T7 x) { + return x.f1 == f1 && x.f2 == f2 && x.f3 == f3 && x.f4 == f4; + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/xml1b/package-info.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/xml1b/package-info.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/xml1b/package-info.java new file mode 100755 index 0000000..306db1b --- /dev/null +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/xml1b/package-info.java @@ -0,0 +1,16 @@ +// *************************************************************************************************************************** +// * 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. * +// *************************************************************************************************************************** +@XmlSchema(prefix="p1",namespace="http://p1") +package org.apache.juneau.xml.xml1b; +import org.apache.juneau.xml.annotation.*; + http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/xml1c/T8.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/xml1c/T8.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/xml1c/T8.java new file mode 100755 index 0000000..0c383eb --- /dev/null +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/xml1c/T8.java @@ -0,0 +1,33 @@ +// *************************************************************************************************************************** +// * 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.juneau.xml.xml1c; + +import org.apache.juneau.xml.annotation.*; + +@Xml(prefix="p2") +@SuppressWarnings("javadoc") +public class T8 { + + public int f1 = 1; + + @Xml(prefix="p1") public int f2 = 2; + + @Xml(prefix="c1") public int f3 = 3; + + @Xml(prefix="f1") + public int f4 = 4; + + public boolean equals(T8 x) { + return x.f1 == f1 && x.f2 == f2 && x.f3 == f3 && x.f4 == f4; + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/xml1c/T9.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/xml1c/T9.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/xml1c/T9.java new file mode 100755 index 0000000..7009626 --- /dev/null +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/xml1c/T9.java @@ -0,0 +1,23 @@ +// *************************************************************************************************************************** +// * 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.juneau.xml.xml1c; + +@SuppressWarnings("javadoc") +public class T9 { + + public int f1 = 1; + + public boolean equals(T9 x) { + return x.f1 == f1; + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/xml1c/package-info.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/xml1c/package-info.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/xml1c/package-info.java new file mode 100755 index 0000000..e054388 --- /dev/null +++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/xml1c/package-info.java @@ -0,0 +1,25 @@ +// *************************************************************************************************************************** +// * 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. * +// *************************************************************************************************************************** +@XmlSchema( + prefix="p1", + xmlNs={ + @XmlNs(prefix="p1",namespaceURI="http://p1"), + @XmlNs(prefix="p2",namespaceURI="http://p2"), + @XmlNs(prefix="p3",namespaceURI="http://p3(unused)"), + @XmlNs(prefix="c1",namespaceURI="http://c1"), + @XmlNs(prefix="f1",namespaceURI="http://f1") + } +) +package org.apache.juneau.xml.xml1c; +import org.apache.juneau.xml.annotation.*; + http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/.classpath ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/.classpath b/juneau-core/juneau-dto/.classpath new file mode 100644 index 0000000..2fd4a04 --- /dev/null +++ b/juneau-core/juneau-dto/.classpath @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" output="target/classes" path="src/main/java"> + <attributes> + <attribute name="optional" value="true"/> + <attribute name="maven.pomderived" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"> + <attributes> + <attribute name="maven.pomderived" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="src" output="target/test-classes" path="src/test/java"> + <attributes> + <attribute name="optional" value="true"/> + <attribute name="maven.pomderived" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> + <attributes> + <attribute name="maven.pomderived" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="output" path="target/classes"/> +</classpath> http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/.gitignore ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/.gitignore b/juneau-core/juneau-dto/.gitignore new file mode 100644 index 0000000..9dd6a50 --- /dev/null +++ b/juneau-core/juneau-dto/.gitignore @@ -0,0 +1,4 @@ +/target/ +/.settings/ +/.DS_Store +/TODO.txt http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/.project ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/.project b/juneau-core/juneau-dto/.project new file mode 100644 index 0000000..12cdbf3 --- /dev/null +++ b/juneau-core/juneau-dto/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>juneau-dto</name> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>edu.umd.cs.findbugs.plugin.eclipse.findbugsBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.m2e.core.maven2Builder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.m2e.core.maven2Nature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + <nature>edu.umd.cs.findbugs.plugin.eclipse.findbugsNature</nature> + </natures> +</projectDescription> http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/pom.xml ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/pom.xml b/juneau-core/juneau-dto/pom.xml new file mode 100644 index 0000000..f85bd93 --- /dev/null +++ b/juneau-core/juneau-dto/pom.xml @@ -0,0 +1,99 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + *************************************************************************************************************************** + * 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. * + *************************************************************************************************************************** +--> +<project + xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.juneau</groupId> + <artifactId>juneau-core</artifactId> + <version>6.3.2-incubating-SNAPSHOT</version> + </parent> + + <artifactId>juneau-dto</artifactId> + <name>Apache Juneau Data Transfer Objects</name> + <description>Data Transfer Objects.</description> + <packaging>bundle</packaging> + + <dependencies> + <dependency> + <groupId>org.apache.juneau</groupId> + <artifactId>juneau-marshall</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + + <properties> + <!-- Skip javadoc generation since we generate them in the aggregate pom --> + <maven.javadoc.skip>true</maven.javadoc.skip> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <version>3.2.0</version> + <extensions>true</extensions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <includes> + <include>**/*Test.class</include> + </includes> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-source-plugin</artifactId> + <executions> + <execution> + <id>attach-sources</id> + <phase>verify</phase> + <goals> + <goal>jar-no-fork</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.jacoco</groupId> + <artifactId>jacoco-maven-plugin</artifactId> + <version>0.7.2.201409121644</version> + <executions> + <execution> + <id>default-prepare-agent</id> + <goals> + <goal>prepare-agent</goal> + </goals> + </execution> + <execution> + <id>default-report</id> + <phase>prepare-package</phase> + <goals> + <goal>report</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/Link.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/Link.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/Link.java new file mode 100644 index 0000000..6677dc0 --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/Link.java @@ -0,0 +1,148 @@ +// *************************************************************************************************************************** +// * 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.juneau.dto; + +import static org.apache.juneau.internal.StringUtils.*; + +import java.text.*; + +import org.apache.juneau.*; +import org.apache.juneau.html.*; +import org.apache.juneau.urlencoding.*; +import org.apache.juneau.utils.*; + +/** + * Simple bean that implements a hyperlink for the HTML serializer. + * + * <p> + * The name and url properties correspond to the following parts of a hyperlink in an HTML document... + * <p class='bcode'> + * <xt><a</xt> <xa>href</xa>=<xs>'href'</xs><xt>></xt>name<xt></a></xt> + * </p> + * + * <p> + * When encountered by the {@link HtmlSerializer} class, this object gets converted to a hyperlink. + * All other serializers simply convert it to a simple bean. + */ +@HtmlLink(nameProperty = "name", hrefProperty = "href") +public class Link implements Comparable<Link> { + private String name, href; + + /** No-arg constructor. */ + public Link() {} + + /** + * Constructor. + * + * @param name Corresponds to the text inside of the <xt><A></xt> element. + * @param href Corresponds to the value of the <xa>href</xa> attribute of the <xt><A></xt> element. + * @param hrefArgs Optional arguments for {@link MessageFormat} style arguments in the href. + */ + public Link(String name, String href, Object...hrefArgs) { + setName(name); + setHref(href, hrefArgs); + } + + + //-------------------------------------------------------------------------------- + // Bean properties + //-------------------------------------------------------------------------------- + + /** + * Bean property getter: <property>name</property>. + * + * <p> + * Corresponds to the text inside of the <xt><A></xt> element. + * + * @return The value of the <property>name</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public String getName() { + return name; + } + + /** + * Bean property setter: <property>name</property>. + * + * @param name The new value for the <property>name</property> property on this bean. + * @return This object (for method chaining). + */ + public Link setName(String name) { + this.name = name; + return this; + } + + /** + * Bean property getter: <property>href</property>. + * + * <p> + * Corresponds to the value of the <xa>href</xa> attribute of the <xt><A></xt> element. + * + * @return The value of the <property>href</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public String getHref() { + return href; + } + + /** + * Bean property setter: <property>href</property>. + * + * @param href The new value for the <property>href</property> property on this bean. + * @return This object (for method chaining). + */ + public Link setHref(String href) { + setHref(href, new Object[0]); + return this; + } + + /** + * Bean property setter: <property>href</property>. + * + * <p> + * Same as {@link #setHref(String)} except allows for {@link MessageFormat} style arguments. + * + * @param href The new href. + * @param args Optional {@link MessageFormat}-style arguments. + * @return This object (for method chaining). + */ + public Link setHref(String href, Object...args) { + for (int i = 0; i < args.length; i++) + args[i] = UrlEncodingSerializer.DEFAULT.serialize(PartType.PATH, args[i]); + this.href = format(href, args); + return this; + } + + /** + * Returns the name so that the {@link PojoQuery} class can search against it. + */ + @Override /* Object */ + public String toString() { + return name; + } + + @Override /* Comparable */ + public int compareTo(Link o) { + return name.compareTo(o.name); + } + + @Override /* Object */ + public boolean equals(Object o) { + if (! (o instanceof Link)) + return false; + return (compareTo((Link)o) == 0); + } + + @Override /* Object */ + public int hashCode() { + return super.hashCode(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/ResultSetList.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/ResultSetList.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/ResultSetList.java new file mode 100644 index 0000000..8fa21ff --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/ResultSetList.java @@ -0,0 +1,112 @@ +// *************************************************************************************************************************** +// * 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.juneau.dto; + +import static org.apache.juneau.internal.IOUtils.*; + +import java.sql.*; +import java.util.*; + +import org.apache.juneau.internal.*; + +/** + * Transforms an SQL {@link ResultSet ResultSet} into a list of maps. + * < + * p> + * Loads the entire result set into an in-memory data structure, and then closes the result set object. + */ +public final class ResultSetList extends LinkedList<Map<String,Object>> { + + private static final long serialVersionUID = 1L; + + /** + * Constructor. + * + * @param rs The result set to load into this DTO. + * @param pos The start position (zero-indexed). + * @param limit The maximum number of rows to retrieve. + * @param includeRowNums Make the first column be the row number. + * @throws SQLException Database error. + */ + public ResultSetList(ResultSet rs, int pos, int limit, boolean includeRowNums) throws SQLException { + try { + int rowNum = pos; + + // Get the column names. + ResultSetMetaData rsmd = rs.getMetaData(); + int offset = (includeRowNums ? 1 : 0); + int cc = rsmd.getColumnCount(); + String[] columns = new String[cc + offset]; + if (includeRowNums) + columns[0] = "ROW"; + int[] colTypes = new int[cc]; + + for (int i = 0; i < cc; i++) { + columns[i+offset] = rsmd.getColumnName(i+1); + colTypes[i] = rsmd.getColumnType(i+1); + } + + while (--pos > 0 && rs.next()) {} + + // Get the rows. + while (limit-- > 0 && rs.next()) { + Object[] row = new Object[cc + offset]; + if (includeRowNums) + row[0] = rowNum++; + for (int i = 0; i < cc; i++) { + Object o = readEntry(rs, i+1, colTypes[i]); + row[i+offset] = o; + } + add(new SimpleMap(columns, row)); + } + } finally { + rs.close(); + } + } + + /** + * Reads the specified column from the current row in the result set. + * + * <p> + * Subclasses can override this method to handle specific data types in special ways. + * + * @param rs The result set to read from. + * @param col The column number (indexed by 1). + * @param dataType The {@link Types type} of the entry. + * @return The entry as an Object. + */ + protected static Object readEntry(ResultSet rs, int col, int dataType) { + try { + switch (dataType) { + case Types.BLOB: + Blob b = rs.getBlob(col); + return "blob["+b.length()+"]"; + case Types.CLOB: + Clob c = rs.getClob(col); + return "clob["+c.length()+"]"; + case Types.LONGVARBINARY: + return "longvarbinary["+count(rs.getBinaryStream(col))+"]"; + case Types.LONGVARCHAR: + return "longvarchar["+count(rs.getAsciiStream(col))+"]"; + case Types.LONGNVARCHAR: + return "longnvarchar["+count(rs.getCharacterStream(col))+"]"; + case Types.TIMESTAMP: + return rs.getTimestamp(col); // Oracle returns com.oracle.TIMESTAMP objects from getObject() which isn't a Timestamp. + default: + return rs.getObject(col); + } + } catch (Exception e) { + return e.getLocalizedMessage(); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/AtomBuilder.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/AtomBuilder.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/AtomBuilder.java new file mode 100644 index 0000000..87c80e5 --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/AtomBuilder.java @@ -0,0 +1,242 @@ +// *************************************************************************************************************************** +// * 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.juneau.dto.atom; + +import java.net.*; +import java.util.*; + +import org.apache.juneau.*; + +/** + * Various useful static methods for creating ATOM elements. + * + * <p> + * Typically, you'll want to do a static import on this class and then call the methods like so... + * <p class='bcode'> + * <jk>import static</jk> org.apache.juneau.dto.atom.AtomBuilder.*; + * + * Feed feed = + * <jsm>feed</jsm>(<js>"tag:juneau.sample.com,2013:1"</js>, <js>"Juneau ATOM specification"</js>, + * <js>"2013-05-08T12:29:29Z"</js>) + * .subtitle(<jsm>text</jsm>(<js>"html"</js>) + * .children(<js>"A <em>lot</em> of effort went into making this effortless"</js>)) + * .links( + * <jsm>link</jsm>(<js>"alternate"</js>, <js>"text/html"</js>, <js>"http://www.sample.com/"</js>) + * .hreflang(<js>"en"</js>), + * <jsm>link</jsm>(<js>"self"</js>, <js>"application/atom+xml"</js>, <js>"http://www.sample.com/feed.atom"</js>) + * ); + * </p> + * + * <h6 class='topic'>Additional Information</h6> + * <ul class='doctree'> + * <li class='link'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs'>Juneau Data Transfer Objects + * (org.apache.juneau.dto)</a> + * <ul> + * <li class='sublink'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs.Atom'>Atom</a> + * </ul> + * </li> + * <li class='jp'> + * <a class='doclink' href='package-summary.html#TOC'>org.apache.juneau.dto.atom</a> + * </li> + * </ul> + */ +public class AtomBuilder { + + /** + * Creates a {@link Category} element with the specified {@link Category#term(String)} attribute. + * + * @param term The {@link Category#term(String)} attribute. + * @return The new element. + */ + public static final Category category(String term) { + return new Category(term); + } + + /** + * Creates a {@link Content} element with the specified {@link Content#type(String)} attribute. + * + * @return The new element. + */ + public static final Content content() { + return new Content(); + } + + /** + * Creates a {@link Content} element. + * + * @param type The {@link Content#type(String)} attribute. + * @return The new element. + */ + public static final Content content(String type) { + return new Content(type); + } + + /** + * Creates an {@link Entry} element with the specified {@link Entry#id(Id)}, {@link Entry#title(Text)}, and + * {@link Entry#updated(Calendar)} attributes. + * + * @param id The {@link Entry#id(Id)} attribute. + * @param title The {@link Entry#title(Text)} attribute. + * @param updated The {@link Entry#updated(Calendar)} attribute. + * @return The new element. + */ + public static final Entry entry(Id id, Text title, Calendar updated) { + return new Entry(id, title, updated); + } + + /** + * Creates an {@link Entry} element with the specified {@link Entry#id(Id)}, {@link Entry#title(Text)}, and + * {@link Entry#updated(Calendar)} attributes. + * + * @param id The {@link Entry#id(Id)} attribute. + * @param title The {@link Entry#title(Text)} attribute. + * @param updated The {@link Entry#updated(Calendar)} attribute. + * @return The new element. + */ + public static final Entry entry(String id, String title, String updated) { + return new Entry(id, title, updated); + } + + /** + * Creates a {@link Feed} element with the specified {@link Feed#id(Id)}, {@link Entry#title(Text)}, and + * {@link Feed#updated(Calendar)} attributes. + * + * @param id The {@link Feed#id(Id)} attribute. + * @param title The {@link Feed#title(Text)} attribute. + * @param updated The {@link Feed#updated(Calendar)} attribute. + * @return The new element. + */ + public static final Feed feed(Id id, Text title, Calendar updated) { + return new Feed(id, title, updated); + } + + /** + * Creates a {@link Feed} element with the specified {@link Feed#id(Id)}, {@link Entry#title(Text)}, and + * {@link Feed#updated(Calendar)} attributes. + * + * @param id The {@link Feed#id(Id)} attribute. + * @param title The {@link Feed#title(Text)} attribute. + * @param updated The {@link Feed#updated(Calendar)} attribute. + * @return The new element. + */ + public static final Feed feed(String id, String title, String updated) { + return new Feed(id, title, updated); + } + + /** + * Creates a {@link Generator} element with the specified {@link Generator#text(String)} child node. + * + * @param text The {@link Generator#text(String)} child node. + * @return The new element. + */ + public static final Generator generator(String text) { + return new Generator(text); + } + + /** + * Creates an {@link Icon} element with the specified {@link Icon#uri(Object)} attribute. + * + * <p> + * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. + * Strings must be valid URIs. + * + * <p> + * URIs defined by {@link UriResolver} can be used for values. + * + * @param uri The {@link Icon#uri(Object)} attribute. + * @return The new element. + */ + public static final Icon icon(Object uri) { + return new Icon(uri); + } + + /** + * Creates an {@link Id} element with the specified {@link Id#text(String)} child node. + * + * @param text The {@link Id#text(String)} child node. + * @return The new element. + */ + public static final Id id(String text) { + return new Id(text); + } + + /** + * Creates a {@link Link} element with the specified {@link Link#rel(String)}, {@link Link#type(String)}, and + * {@link Link#href(String)} attributes. + * + * @param rel The {@link Link#rel(String)} attribute. + * @param type The {@link Link#type(String)} attribute. + * @param href The {@link Link#href(String)} attribute. + * @return The new element. + */ + public static final Link link(String rel, String type, String href) { + return new Link(rel, type, href); + } + + /** + * Creates a {@link Logo} element with the specified {@link Logo#uri(Object)} attribute. + * + * <p> + * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. + * Strings must be valid URIs. + * + * <p> + * URIs defined by {@link UriResolver} can be used for values. + * + * @param uri The {@link Logo#uri(Object)} attribute. + * @return The new element. + */ + public static final Logo logo(Object uri) { + return new Logo(uri); + } + + /** + * Creates a {@link Person} element with the specified {@link Person#name(String)} attribute. + * + * @param name The {@link Person#name(String)} attribute. + * @return The new element. + */ + public static final Person person(String name) { + return new Person(name); + } + + /** + * Creates a {@link Source} element. + * + * @return The new element. + */ + public static final Source source() { + return new Source(); + } + + /** + * Creates a {@link Text} element. + * + * @return The new element. + */ + public static final Text text() { + return new Text(); + } + + /** + * Creates a {@link Text} element with the specified {@link Text#type(String)} attribute. + * + * @param type The {@link Text#type(String)} attribute. + * @return The new element. + */ + public static final Text text(String type) { + return new Text(type); + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Category.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Category.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Category.java new file mode 100644 index 0000000..4f0e583 --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Category.java @@ -0,0 +1,167 @@ +// *************************************************************************************************************************** +// * 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.juneau.dto.atom; + +import static org.apache.juneau.internal.StringUtils.*; +import static org.apache.juneau.xml.annotation.XmlFormat.*; + +import java.net.*; +import java.net.URI; + +import org.apache.juneau.*; +import org.apache.juneau.annotation.*; +import org.apache.juneau.xml.annotation.*; + +/** + * Represents an <code>atomCategory</code> construct in the RFC4287 specification. + * + * <h6 class='figure'>Schema</h6> + * <p class='bcode'> + * atomCategory = + * element atom:category { + * atomCommonAttributes, + * attribute term { text }, + * attribute scheme { atomUri }?, + * attribute label { text }?, + * undefinedContent + * } + * </p> + * + * <h6 class='topic'>Additional Information</h6> + * <ul class='doctree'> + * <li class='link'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs'>Juneau Data Transfer Objects + * (org.apache.juneau.dto)</a> + * <ul> + * <li class='sublink'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs.Atom'>Atom</a> + * </ul> + * </li> + * <li class='jp'> + * <a class='doclink' href='package-summary.html#TOC'>org.apache.juneau.dto.atom</a> + * </li> + * </ul> + */ +@Bean(typeName="category") +@SuppressWarnings("hiding") +public class Category extends Common { + + private String term; + private URI scheme; + private String label; + + /** + * Normal constructor. + * + * @param term The category term. + */ + public Category(String term) { + term(term); + } + + /** Bean constructor. */ + public Category() {} + + + //-------------------------------------------------------------------------------- + // Bean properties + //-------------------------------------------------------------------------------- + + /** + * @return The category term. + */ + @Xml(format=ATTR) + public String getTerm() { + return term; + } + + /** + * Sets the category term. + * + * @param term The category term. + * @return This object (for method chaining). + */ + @BeanProperty("term") + public Category term(String term) { + this.term = term; + return this; + } + + /** + * Returns the category scheme. + * + * @return The category scheme. + */ + @Xml(format=ATTR) + public URI getScheme() { + return scheme; + } + + /** + * Sets the category scheme. + * + * <p> + * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. + * Strings must be valid URIs. + * + * <p> + * URIs defined by {@link UriResolver} can be used for values. + * + * @param scheme The category scheme. + * @return This object (for method chaining). + */ + @BeanProperty("scheme") + public Category scheme(Object scheme) { + this.scheme = toURI(scheme); + return this; + } + + /** + * Returns the category label. + * + * @return The category label. + */ + @Xml(format=ATTR) + public String getLabel() { + return label; + } + + /** + * Sets the category label. + * + * @param label The category label. + * @return This object (for method chaining). + */ + @BeanProperty("label") + public Category label(String label) { + this.label = label; + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden setters (to simplify method chaining) + //-------------------------------------------------------------------------------- + + @Override /* Common */ + public Category base(Object base) { + super.base(base); + return this; + } + + @Override /* Common */ + public Category lang(String lang) { + super.lang(lang); + return this; + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Common.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Common.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Common.java new file mode 100644 index 0000000..544b8f2 --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Common.java @@ -0,0 +1,112 @@ +// *************************************************************************************************************************** +// * 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.juneau.dto.atom; + +import static org.apache.juneau.internal.StringUtils.*; +import static org.apache.juneau.xml.annotation.XmlFormat.*; + +import java.net.*; +import java.net.URI; + +import org.apache.juneau.*; +import org.apache.juneau.annotation.*; +import org.apache.juneau.xml.annotation.*; + +/** + * Represents an <code>atomCommonAttributes</code> construct in the RFC4287 specification. + * + * <h6 class='figure'>Schema</h6> + * <p class='bcode'> + * atomCommonAttributes = + * attribute xml:base { atomUri }?, + * attribute xml:lang { atomLanguageTag }?, + * undefinedAttribute* + * </p> + * + * <h6 class='topic'>Additional Information</h6> + * <ul class='doctree'> + * <li class='link'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs'>Juneau Data Transfer Objects + * (org.apache.juneau.dto)</a> + * <ul> + * <li class='sublink'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs.Atom'>Atom</a> + * </ul> + * </li> + * <li class='jp'> + * <a class='doclink' href='package-summary.html#TOC'>org.apache.juneau.dto.atom</a> + * </li> + * </ul> + */ +@SuppressWarnings("hiding") +public abstract class Common { + + private URI base; + private String lang; + + + //-------------------------------------------------------------------------------- + // Bean properties + //-------------------------------------------------------------------------------- + + /** + * Returns the uri base of this object. + * + * @return The URI base of this object. + */ + @Xml(prefix="xml", format=ATTR) + public URI getBase() { + return base; + } + + /** + * Sets the URI base of this object. + * + * <p> + * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. + * Strings must be valid URIs. + * + * <p> + * URIs defined by {@link UriResolver} can be used for values. + * + * @param base The URI base of this object. + * @return This object (for method chaining). + */ + @BeanProperty("base") + public Common base(Object base) { + this.base = toURI(base); + return this; + } + + /** + * Returns the language of this object. + * + * @return The language of this object. + */ + @Xml(prefix="xml", format=ATTR) + public String getLang() { + return lang; + } + + /** + * Sets the language of this object. + * + * @param lang The language of this object. + * @return This object (for method chaining). + */ + @BeanProperty("lang") + public Common lang(String lang) { + this.lang = lang; + return this; + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/CommonEntry.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/CommonEntry.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/CommonEntry.java new file mode 100644 index 0000000..32e34d2 --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/CommonEntry.java @@ -0,0 +1,302 @@ +// *************************************************************************************************************************** +// * 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.juneau.dto.atom; + +import static org.apache.juneau.dto.atom.Utils.*; +import static org.apache.juneau.xml.annotation.XmlFormat.*; + +import java.util.*; + +import org.apache.juneau.annotation.*; +import org.apache.juneau.transforms.*; +import org.apache.juneau.xml.annotation.*; + +/** + * Parent class of {@link Entry}, {@link Feed}, and {@link Source} + * + * <h6 class='topic'>Additional Information</h6> + * <ul class='doctree'> + * <li class='link'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs'>Juneau Data Transfer Objects + * (org.apache.juneau.dto)</a> + * <ul> + * <li class='sublink'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs.Atom'>Atom</a> + * </ul> + * </li> + * <li class='jp'> + * <a class='doclink' href='package-summary.html#TOC'>org.apache.juneau.dto.atom</a> + * </li> + * </ul> + */ +@SuppressWarnings("hiding") +public class CommonEntry extends Common { + + private Person[] authors; + private Category[] categories; + private Person[] contributors; + private Id id; + private Link[] links; + private Text rights; + private Text title; + private Calendar updated; + + + /** + * Normal constructor. + * + * @param id The ID of this object. + * @param title The title of this object. + * @param updated The updated timestamp of this object. + */ + public CommonEntry(Id id, Text title, Calendar updated) { + id(id).title(title).updated(updated); + } + + /** + * Normal constructor. + * + * @param id The ID of this object. + * @param title The title of this object. + * @param updated The updated timestamp of this object. + */ + public CommonEntry(String id, String title, String updated) { + id(id).title(title).updated(updated); + } + + /** Bean constructor. */ + public CommonEntry() {} + + + //-------------------------------------------------------------------------------- + // Bean properties + //-------------------------------------------------------------------------------- + + /** + * Returns the list of authors for this object. + * + * @return The list of authors for this object. + */ + @Xml(format=COLLAPSED, childName="author") + public Person[] getAuthors() { + return authors; + } + + /** + * Sets the list of authors for this object. + * + * @param authors The list of authors for this object. + * @return This object (for method chaining). + */ + @BeanProperty("authors") + public CommonEntry authors(Person...authors) { + this.authors = authors; + return this; + } + + /** + * Returns the list of categories of this object. + * + * @return The list of categories of this object. + */ + @Xml(format=COLLAPSED, childName="category") + public Category[] getCatetories() { + return categories; + } + + /** + * Sets the list of categories of this object. + * + * @param categories The list of categories of this object. + * @return This object (for method chaining). + */ + @BeanProperty("categories") + public CommonEntry categories(Category...categories) { + this.categories = categories; + return this; + } + + /** + * Returns the list of contributors of this object. + * + * @return The list of contributors of this object. + */ + @Xml(format=COLLAPSED, childName="contributor") + public Person[] getContributors() { + return contributors; + } + + /** + * Sets the list of contributors of this object. + * + * @param contributors The list of contributors of this object. + * @return This object (for method chaining). + */ + @BeanProperty("contributors") + public CommonEntry contributors(Person...contributors) { + this.contributors = contributors; + return this; + } + + /** + * Returns the ID of this object. + * + * @return The ID of this object. + */ + public Id getId() { + return id; + } + + /** + * Sets the ID of this object. + * + * @param id The ID of this object. + * @return This object (for method chaining). + */ + @BeanProperty("id") + public CommonEntry id(Id id) { + this.id = id; + return this; + } + + /** + * Sets the ID of this object. + * + * @param id The ID of this object. + * @return This object (for method chaining). + */ + public CommonEntry id(String id) { + this.id = new Id(id); + return this; + } + + /** + * Returns the list of links of this object. + * + * @return The list of links of this object. + */ + @Xml(format=COLLAPSED) + public Link[] getLinks() { + return links; + } + + /** + * Sets the list of links of this object. + * + * @param links The list of links of this object. + * @return This object (for method chaining). + */ + @BeanProperty("links") + public CommonEntry links(Link...links) { + this.links = links; + return this; + } + + /** + * Returns the rights statement of this object. + * + * @return The rights statement of this object. + */ + public Text getRights() { + return rights; + } + + /** + * Sets the rights statement of this object. + * + * @param rights The rights statement of this object. + * @return This object (for method chaining). + */ + @BeanProperty("rights") + public CommonEntry rights(Text rights) { + this.rights = rights; + return this; + } + + /** + * Sets the rights statement of this object. + * + * @param rights The rights statement of this object. + * @return This object (for method chaining). + */ + public CommonEntry rights(String rights) { + this.rights = new Text().text(rights); + return this; + } + + /** + * Returns the title of this object. + * + * @return The title of this object. + */ + public Text getTitle() { + return title; + } + + /** + * Sets the title of this object. + * + * @param title The title of this object. + * @return This object (for method chaining). + */ + @BeanProperty("title") + public CommonEntry title(Text title) { + this.title = title; + return this; + } + + /** + * Sets the title of this object. + * + * @param title The title of this object. + * @return This object (for method chaining). + */ + public CommonEntry title(String title) { + this.title = new Text().text(title); + return this; + } + + /** + * Returns the update timestamp of this object. + * + * @return The update timestamp of this object. + */ + @BeanProperty(swap=CalendarSwap.ISO8601DT.class) + public Calendar getUpdated() { + return updated; + } + + /** + * Sets the update timestamp of this object. + * + * @param updated The update timestamp of this object. + * @return This object (for method chaining). + */ + @BeanProperty("updated") + public CommonEntry updated(Calendar updated) { + this.updated = updated; + return this; + } + + /** + * Sets the update timestamp of this object. + * + * @param updated The update timestamp of this object in ISO8601 format. + * @return This object (for method chaining). + */ + @BeanProperty("updated") + public CommonEntry updated(String updated) { + this.updated = parseDateTime(updated); + return this; + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Content.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Content.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Content.java new file mode 100644 index 0000000..e90c674 --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Content.java @@ -0,0 +1,163 @@ +// *************************************************************************************************************************** +// * 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.juneau.dto.atom; + +import static org.apache.juneau.internal.StringUtils.*; +import static org.apache.juneau.xml.annotation.XmlFormat.*; + +import java.net.*; +import java.net.URI; + +import org.apache.juneau.*; +import org.apache.juneau.annotation.*; +import org.apache.juneau.xml.annotation.*; + +/** + * Represents an <code>atomContent</code> construct in the RFC4287 specification. + * + * <h6 class='figure'>Schema</h6> + * <p class='bcode'> + * atomContent = atomInlineTextContent + * | atomInlineXHTMLContent + * | atomInlineOtherContent + * | atomOutOfLineContent + * + * atomInlineTextContent = + * element atom:content { + * atomCommonAttributes, + * attribute type { "text" | "html" }?, + * (text)* + * } + * + * atomInlineXHTMLContent = + * element atom:content { + * atomCommonAttributes, + * attribute type { "xhtml" }, + * xhtmlDiv + * } + * + * atomInlineOtherContent = + * element atom:content { + * atomCommonAttributes, + * attribute type { atomMediaType }?, + * (text|anyElement)* + * } + * + * atomOutOfLineContent = + * element atom:content { + * atomCommonAttributes, + * attribute type { atomMediaType }?, + * attribute src { atomUri }, + * empty + * } + * </p> + * + * <h6 class='topic'>Additional Information</h6> + * <ul class='doctree'> + * <li class='link'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs'>Juneau Data Transfer Objects + * (org.apache.juneau.dto)</a> + * <ul> + * <li class='sublink'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs.Atom'>Atom</a> + * </ul> + * </li> + * <li class='jp'> + * <a class='doclink' href='package-summary.html#TOC'>org.apache.juneau.dto.atom</a> + * </li> + * </ul> + */ +@SuppressWarnings("hiding") +public class Content extends Text { + + private URI src; + + + /** + * Normal content. + * + * @param type The content type of this content. + */ + public Content(String type) { + super(type); + } + + /** + * Normal content. + */ + public Content() { + super(); + } + + + //-------------------------------------------------------------------------------- + // Bean properties + //-------------------------------------------------------------------------------- + + /** + * Returns the source URI. + * + * @return the source URI. + */ + @Xml(format=ATTR) + public URI getSrc() { + return src; + } + + /** + * Sets the source URI. + * + * <p> + * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. + * Strings must be valid URIs. + * + * <p> + * URIs defined by {@link UriResolver} can be used for values. + * + * @param src The source URI. + * @return This object (for method chaining). + */ + @BeanProperty("src") + public Content src(Object src) { + this.src = toURI(src); + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden setters (to simplify method chaining) + //-------------------------------------------------------------------------------- + + @Override /* Text */ + public Content text(String text) { + super.text(text); + return this; + } + + @Override /* Text */ + public Content type(String type) { + super.type(type); + return this; + } + + @Override /* Common */ + public Content base(Object base) { + super.base(base); + return this; + } + @Override /* Common */ + public Content lang(String lang) { + super.lang(lang); + return this; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Entry.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Entry.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Entry.java new file mode 100644 index 0000000..2bd640b --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Entry.java @@ -0,0 +1,291 @@ +// *************************************************************************************************************************** +// * 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.juneau.dto.atom; + +import static org.apache.juneau.dto.atom.Utils.*; + +import java.util.*; + +import org.apache.juneau.annotation.*; +import org.apache.juneau.transforms.*; + +/** + * Represents an <code>atomEntry</code> construct in the RFC4287 specification. + * + * <h6 class='figure'>Schema</h6> + * <p class='bcode'> + * atomEntry = + * element atom:entry { + * atomCommonAttributes, + * (atomAuthor* + * & atomCategory* + * & atomContent? + * & atomContributor* + * & atomId + * & atomLink* + * & atomPublished? + * & atomRights? + * & atomSource? + * & atomSummary? + * & atomTitle + * & atomUpdated + * & extensionElement*) + * } + * </p> + * + * <h6 class='topic'>Additional Information</h6> + * <ul class='doctree'> + * <li class='link'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs'>Juneau Data Transfer Objects + * (org.apache.juneau.dto)</a> + * <ul> + * <li class='sublink'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs.Atom'>Atom</a> + * </ul> + * </li> + * <li class='jp'> + * <a class='doclink' href='package-summary.html#TOC'>org.apache.juneau.dto.atom</a> + * </li> + * </ul> + */ +@Bean(typeName="entry") +@SuppressWarnings("hiding") +public class Entry extends CommonEntry { + + private Content content; + private Calendar published; + private Source source; + private Text summary; + + /** + * Normal constructor. + * + * @param id The ID of this entry. + * @param title The title of this entry. + * @param updated The updated timestamp of this entry. + */ + public Entry(Id id, Text title, Calendar updated) { + super(id, title, updated); + } + + /** + * Normal constructor. + * + * @param id The ID of this entry. + * @param title The title of this entry. + * @param updated The updated timestamp of this entry. + */ + public Entry(String id, String title, String updated) { + super(id, title, updated); + } + + /** Bean constructor. */ + public Entry() {} + + + //-------------------------------------------------------------------------------- + // Bean properties + //-------------------------------------------------------------------------------- + + /** + * Returns the content of this entry. + * + * @return The content of this entry. + */ + public Content getContent() { + return content; + } + + /** + * Sets the content of this entry. + * + * @param content The content of this entry. + * @return This object (for method chaining). + */ + @BeanProperty("content") + public Entry content(Content content) { + this.content = content; + return this; + } + + /** + * Returns the publish timestamp of this entry. + * + * @return The publish timestamp of this entry. + */ + @BeanProperty(swap=CalendarSwap.ISO8601DT.class) + public Calendar getPublished() { + return published; + } + + /** + * Sets the publish timestamp of this entry. + * + * @param published The publish timestamp of this entry. + * @return This object (for method chaining). + */ + @BeanProperty("published") + public Entry published(Calendar published) { + this.published = published; + return this; + } + + /** + * Sets the publish timestamp of this entry. + * + * @param published The publish timestamp of this entry in ISO8601 format. + * @return This object (for method chaining). + */ + @BeanProperty("published") + public Entry published(String published) { + this.published = parseDateTime(published); + return this; + } + + /** + * Returns the source of this entry. + * + * @return The source of this entry. + */ + public Source getSource() { + return source; + } + + /** + * Sets the source of this entry. + * + * @param source The source of this entry. + * @return This object (for method chaining). + */ + @BeanProperty("source") + public Entry source(Source source) { + this.source = source; + return this; + } + + /** + * Returns the summary of this entry. + * + * @return The summary of this entry. + */ + public Text getSummary() { + return summary; + } + + /** + * Sets the summary of this entry. + * + * @param summary The summary of this entry. + * @return This object (for method chaining). + */ + @BeanProperty("summary") + public Entry summary(Text summary) { + this.summary = summary; + return this; + } + + /** + * Sets the summary of this entry. + * + * @param summary The summary of this entry. + * @return This object (for method chaining). + */ + @BeanProperty("summary") + public Entry summary(String summary) { + this.summary = new Text(summary); + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden setters (to simplify method chaining) + //-------------------------------------------------------------------------------- + + @Override /* CommonEntry */ + public Entry authors(Person...authors) { + super.authors(authors); + return this; + } + + @Override /* CommonEntry */ + public Entry categories(Category...categories) { + super.categories(categories); + return this; + } + + @Override /* CommonEntry */ + public Entry contributors(Person...contributors) { + super.contributors(contributors); + return this; + } + + @Override /* CommonEntry */ + public Entry id(Id id) { + super.id(id); + return this; + } + + @Override /* CommonEntry */ + public Entry links(Link...links) { + super.links(links); + return this; + } + + @Override /* CommonEntry */ + public Entry rights(Text rights) { + super.rights(rights); + return this; + } + + @Override /* CommonEntry */ + public Entry rights(String rights) { + super.rights(rights); + return this; + } + + @Override /* CommonEntry */ + public Entry title(Text title) { + super.title(title); + return this; + } + + @Override /* CommonEntry */ + public Entry title(String title) { + super.title(title); + return this; + } + + @Override /* CommonEntry */ + public Entry updated(Calendar updated) { + super.updated(updated); + return this; + } + + @Override /* CommonEntry */ + public Entry updated(String updated) { + super.updated(updated); + return this; + } + + @Override /* Common */ + public Entry base(Object base) { + super.base(base); + return this; + } + + @Override /* Common */ + public Entry lang(String lang) { + super.lang(lang); + return this; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Feed.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Feed.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Feed.java new file mode 100644 index 0000000..4c5ca0b --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/atom/Feed.java @@ -0,0 +1,305 @@ +// *************************************************************************************************************************** +// * 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.juneau.dto.atom; + +import static org.apache.juneau.xml.annotation.XmlFormat.*; + +import java.util.*; + +import org.apache.juneau.annotation.*; +import org.apache.juneau.xml.annotation.*; + +/** + * Top-level ATOM feed object. + * + * <p> + * Represents an <code>atomFeed</code> construct in the RFC4287 specification. + * + * <h6 class='figure'>Schema</h6> + * <p class='bcode'> + * atomFeed = + * element atom:feed { + * atomCommonAttributes, + * (atomAuthor* + * & atomCategory* + * & atomContributor* + * & atomGenerator? + * & atomIcon? + * & atomId + * & atomLink* + * & atomLogo? + * & atomRights? + * & atomSubtitle? + * & atomTitle + * & atomUpdated + * & extensionElement*), + * atomEntry* + * } + * </p> + * + * <h6 class='topic'>Additional Information</h6> + * <ul class='doctree'> + * <li class='link'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs'>Juneau Data Transfer Objects + * (org.apache.juneau.dto)</a> + * <ul> + * <li class='sublink'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs.Atom'>Atom</a> + * </ul> + * </li> + * <li class='jp'> + * <a class='doclink' href='package-summary.html#TOC'>org.apache.juneau.dto.atom</a> + * </li> + * </ul> + */ +@Bean(typeName="feed") +@SuppressWarnings("hiding") +public class Feed extends CommonEntry { + + private Generator generator; // atomGenerator? + private Icon icon; // atomIcon? + private Logo logo; // atomLogo? + private Text subtitle; // atomSubtitle? + private Entry[] entries; // atomEntry* + + /** + * Normal constructor. + * + * @param id The feed identifier. + * @param title The feed title. + * @param updated The feed updated timestamp. + */ + public Feed(Id id, Text title, Calendar updated) { + super(id, title, updated); + } + + /** + * Normal constructor. + * + * @param id The feed identifier. + * @param title The feed title. + * @param updated The feed updated timestamp. + */ + public Feed(String id, String title, String updated) { + super(id, title, updated); + } + + /** Bean constructor. */ + public Feed() {} + + + //-------------------------------------------------------------------------------- + // Bean properties + //-------------------------------------------------------------------------------- + + /** + * Returns generator information on this feed. + * + * @return The generator information on this feed. + */ + public Generator getGenerator() { + return generator; + } + + /** + * Sets the generator information on this feed. + * + * @param generator The generator information on this feed. + * @return This object (for method chaining). + */ + @BeanProperty("generator") + public Feed generator(Generator generator) { + this.generator = generator; + return this; + } + + /** + * Returns the feed icon. + * + * @return The feed icon. + */ + public Icon getIcon() { + return icon; + } + + /** + * Sets the feed icon. + * + * @param icon The feed icon. + * @return This object (for method chaining). + */ + @BeanProperty("icon") + public Feed icon(Icon icon) { + this.icon = icon; + return this; + } + + /** + * Returns the feed logo. + * + * @return The feed logo. + */ + public Logo getLogo() { + return logo; + } + + /** + * Sets the feed logo. + * + * @param logo The feed logo. + * @return This object (for method chaining). + */ + @BeanProperty("logo") + public Feed logo(Logo logo) { + this.logo = logo; + return this; + } + + /** + * Returns the feed subtitle. + * + * @return The feed subtitle. + */ + @BeanProperty("subtitle") + public Text getSubTitle() { + return subtitle; + } + + /** + * Sets the feed subtitle. + * + * @param subtitle The feed subtitle. + * @return This object (for method chaining). + */ + @BeanProperty("subtitle") + public Feed subtitle(Text subtitle) { + this.subtitle = subtitle; + return this; + } + + /** + * Sets the feed subtitle. + * + * @param subtitle The feed subtitle. + * @return This object (for method chaining). + */ + public Feed subtitle(String subtitle) { + this.subtitle = new Text(subtitle); + return this; + } + + /** + * Returns the entries in the feed. + * + * @return The entries in the feed. + */ + @Xml(format=COLLAPSED) + public Entry[] getEntries() { + return entries; + } + + /** + * Sets the entries in the feed. + * + * @param entries The entries in the feed. + * @return This object (for method chaining). + */ + @BeanProperty("entries") + public Feed entries(Entry...entries) { + this.entries = entries; + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden setters (to simplify method chaining) + //-------------------------------------------------------------------------------- + + @Override /* CommonEntry */ + public Feed authors(Person...authors) { + super.authors(authors); + return this; + } + + @Override /* CommonEntry */ + public Feed categories(Category...categories) { + super.categories(categories); + return this; + } + + @Override /* CommonEntry */ + public Feed contributors(Person...contributors) { + super.contributors(contributors); + return this; + } + + @Override /* CommonEntry */ + public Feed id(Id id) { + super.id(id); + return this; + } + + @Override /* CommonEntry */ + public Feed links(Link...links) { + super.links(links); + return this; + } + + @Override /* CommonEntry */ + public Feed rights(Text rights) { + super.rights(rights); + return this; + } + + @Override /* CommonEntry */ + public Feed rights(String rights) { + super.rights(rights); + return this; + } + + @Override /* CommonEntry */ + public Feed title(Text title) { + super.title(title); + return this; + } + + @Override /* CommonEntry */ + public Feed title(String title) { + super.title(title); + return this; + } + + @Override /* CommonEntry */ + public Feed updated(Calendar updated) { + super.updated(updated); + return this; + } + + @Override /* CommonEntry */ + public Feed updated(String updated) { + super.updated(updated); + return this; + } + + @Override /* Common */ + public Feed base(Object base) { + super.base(base); + return this; + } + + @Override /* Common */ + public Feed lang(String lang) { + super.lang(lang); + return this; + } +}
