com.avaje.ebean.text
Class PathProperties

java.lang.Object
  extended by com.avaje.ebean.text.PathProperties

public class PathProperties
extends Object

This is a Tree like structure of paths and properties that can be used for defining which parts of an object graph to render in JSON or XML, and can also be used to define which parts to select and fetch for an ORM query.

It provides a way of parsing a string representation of nested path properties and applying that to both what to fetch (ORM query) and what to render (JAX-RS JSON / XML).

Author:
rbygrave

Nested Class Summary
static class PathProperties.Props
           
 
Constructor Summary
PathProperties()
          Construct an empty PathProperties.
 
Method Summary
 void addToPath(String path, String property)
           
 void apply(Query<?> query)
          Apply these path properties as fetch paths to the query.
 PathProperties copy()
          Create a copy of this instance so that it can be modified.
 Set<String> get(String path)
          Get the properties for a given path.
 Collection<PathProperties.Props> getPathProps()
           
 Set<String> getPaths()
          Return a shallow copy of the paths.
 boolean hasPath(String path)
          Return true if the path is defined and has properties.
 boolean isEmpty()
          Return true if there are no paths defined.
static PathProperties parse(String source)
          Parse and return a PathProperties from nested string format like (a,b,c(d,e),f(g)) where "c" is a path containing "d" and "e" and "f" is a path containing "g" and the root path contains "a","b","c" and "f".
 void put(String path, Set<String> properties)
          Set the properties for a given path.
 Set<String> remove(String path)
          Remove a path returning the properties set for that path.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PathProperties

public PathProperties()
Construct an empty PathProperties.

Method Detail

parse

public static PathProperties parse(String source)
Parse and return a PathProperties from nested string format like (a,b,c(d,e),f(g)) where "c" is a path containing "d" and "e" and "f" is a path containing "g" and the root path contains "a","b","c" and "f".


copy

public PathProperties copy()
Create a copy of this instance so that it can be modified.

For example, you may want to create a copy to add extra properties to a path so that they are fetching in a ORM query but perhaps not rendered by default. That is, use a PathProperties for JSON or XML rendering, but create a copy, add some extra properties and then use that copy to define an ORM query.


isEmpty

public boolean isEmpty()
Return true if there are no paths defined.


toString

public String toString()
Overrides:
toString in class Object

hasPath

public boolean hasPath(String path)
Return true if the path is defined and has properties.


get

public Set<String> get(String path)
Get the properties for a given path.


addToPath

public void addToPath(String path,
                      String property)

put

public void put(String path,
                Set<String> properties)
Set the properties for a given path.


remove

public Set<String> remove(String path)
Remove a path returning the properties set for that path.


getPaths

public Set<String> getPaths()
Return a shallow copy of the paths.


getPathProps

public Collection<PathProperties.Props> getPathProps()

apply

public void apply(Query<?> query)
Apply these path properties as fetch paths to the query.



Copyright © 2010. All Rights Reserved.