com.rexsl.page
Class JaxbGroup

java.lang.Object
  extended by com.rexsl.page.JaxbGroup

public final class JaxbGroup
extends Object

JAXB group of elements.

A convenient utility class that enables on-fly creation of JAXB annotated collections of elements, for example:

 @XmlRootElement
 public class Page {
   @XmlElement
   public Object getEmployees() {
     Collection<Employee> employees = this.retrieve();
     return JaxbGroup.build(employees, "employee");
   }
 }
 

It's even more convenient in combination with JaxbBundle, for example:

 @XmlRootElement
 public class Page {
   @XmlElement
   public Object getEmployee() {
     return new JaxbBundle("employee")
       .attr("age", "45")
       .add("depts", JaxbGroup.build(this.depts(), "dept"))
       .up()
       .element();
   }
 }
 

The class is immutable and thread-safe.

Since:
0.3.7
Version:
$Id: JaxbGroup.java 1758 2012-05-28 14:51:16Z guard $
Author:
Yegor Bugayenko (yegor@rexsl.com)

Constructor Summary
  JaxbGroup()
          Public ctor, for JAXB (always throws a runtime exception).
protected JaxbGroup(Collection<?> grp)
          Protected ctor, for on-fly instantiating (you're not supposed to use it).
 
Method Summary
static Object build(Collection<?> grp, String name)
          Creates a new JAXB-annotated collection of elements.
 Collection<?> getGroup()
          Get group of elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JaxbGroup

public JaxbGroup()
Public ctor, for JAXB (always throws a runtime exception).


JaxbGroup

protected JaxbGroup(Collection<?> grp)
Protected ctor, for on-fly instantiating (you're not supposed to use it).

Parameters:
grp - Group of elements
Method Detail

build

public static Object build(@NotNull
                           Collection<?> grp,
                           @NotNull
                           String name)
Creates a new JAXB-annotated collection of elements.

Parameters:
grp - Group of elements (JAXB-annotated)
name - Name of parent XML element
Returns:
JAXB-annotated object, just created

getGroup

public Collection<?> getGroup()
Get group of elements.

Returns:
The collection


Copyright © 2011-2012 ReXSL.com. All Rights Reserved.