org.modeshape.web.jcr.rest.client.json

## Class NodeTypeNode

- java.lang.Object
- - org.codehaus.jettison.json.JSONObject
  - - org.modeshape.web.jcr.rest.client.json.JsonNode
    - - org.modeshape.web.jcr.rest.client.json.NodeTypeNode

- All Implemented Interfaces:
    Serializable

      @Immutable
      public final class NodeTypeNode
      extends JsonNode

  The `NodeTypeNode` class is responsible for knowing how to obtain a NodeType based on the Workspace.
  An example `URL` to obtain all the node types would look like:
  {context root}/{repository name}/{workspace name}/items/jcr:system/jcr:nodeTypes"
  And an example url to obtain a specific node type would look like:
  {context root}/{repository name}/{workspace name}/items/jcr:system/jcr:nodeTypes/{node type name}
  A Node Type will not be created if:
- jcr:isMixin is true
- jcr:multiple is true

See Also:
  Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static int` | `NODE_TYPE_DEPTH`
    `protected static String` | `NODE_TYPES_PATH`

    - ### Fields inherited from class org.codehaus.jettison.json.JSONObject

      `NULL`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `NodeTypeNode(Workspace workspace)` Use this constructor if wanting all node types for a workspace
    `NodeTypeNode(Workspace workspace, String nodeTypeName)` Use this constructor if wanting all node types for a workspace

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected ChildNodeDefinition` | `createChildNodeDefinition(String defnName, org.codehaus.jettison.json.JSONObject body, String declaringNodeTypeName, Map<String,NodeType> nodeTypes)`
    `protected void` | `createNodeType(String name, org.codehaus.jettison.json.JSONObject body, Map<String,NodeType> nodeTypes)`
    `protected PropertyDefinition` | `createPropertyDefinition(String defnName, org.codehaus.jettison.json.JSONObject body, String declaringNodeTypeName, Map<String,NodeType> nodeTypes)`
    `Map<String,NodeType>` | `getNodeTypes(String jsonResponse)`
    `String` | `getPath()`
    `protected String` | `getPrimaryType(String key, org.codehaus.jettison.json.JSONObject child)`
    `URL` | `getUrl()` The URL will NOT end in '/'.
    `protected int` | `typeValueFrom(org.codehaus.jettison.json.JSONObject properties, String name, int defaultType)`
    `protected String` | `valueFrom(org.codehaus.jettison.json.JSONObject properties, String name)`
    `protected boolean` | `valueFrom(org.codehaus.jettison.json.JSONObject properties, String name, boolean defaultValue)`
    `protected String` | `valueFrom(org.codehaus.jettison.json.JSONObject properties, String name, String defaultValue)`
    `protected List<String>` | `valuesFrom(org.codehaus.jettison.json.JSONObject properties, String name)`

    - ### Methods inherited from class org.modeshape.web.jcr.rest.client.json.JsonNode

      `children, getContent, getId, properties, toString, withChild, withMixin, withPrimaryType, withProperty`

    - ### Methods inherited from class org.codehaus.jettison.json.JSONObject

      `accumulate, append, doubleToString, get, getBoolean, getDouble, getInt, getJSONArray, getJSONObject, getLong, getString, has, isNull, keys, length, names, numberToString, opt, optBoolean, optBoolean, optDouble, optDouble, optInt, optInt, optJSONArray, optJSONObject, optLong, optLong, optString, optString, put, put, put, put, put, put, put, putOpt, quote, remove, toJSONArray, toString, write`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### NODE_TYPES_PATH

          protected static final String NODE_TYPES_PATH

      See Also:
        Constant Field Values

    - #### NODE_TYPE_DEPTH

          protected static final int NODE_TYPE_DEPTH

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### NodeTypeNode

          public NodeTypeNode(Workspace workspace)
                       throws Exception

      Use this constructor if wanting all node types for a workspace
      Parameters:
        `workspace` - the workspace being used (never `null`)
      Throws:
        `Exception` - if there is a problem creating the folder node

    - #### NodeTypeNode

          public NodeTypeNode(Workspace workspace,
                      String nodeTypeName)
                       throws Exception

      Use this constructor if wanting all node types for a workspace
      Parameters:
        `workspace` - the workspace being used (never `null`)
        `nodeTypeName` - the node type name; may not be null
      Throws:
        `Exception` - if there is a problem creating the folder node

  - ### Method Detail

    - #### getPath

          public String getPath()

      Returns:
        the full path of folder within the workspace

    - #### getUrl

          public URL getUrl()
                     throws Exception

      The URL will NOT end in '/'.

      Specified by:
        `getUrl` in class `JsonNode`
      Returns:
        an HTTP URL representing this node
      Throws:
        `Exception` - if there is a problem constructing the URL
      See Also:
        `JsonNode.getUrl()`

    - #### getNodeTypes

          public Map<String,NodeType> getNodeTypes(String jsonResponse)
                                            throws Exception

      Parameters:
        `jsonResponse` - the HTTP connection JSON response (never `null`) containing the NodeTypes
      Returns:
        the node types for this workspace (never `null`)
      Throws:
        `Exception` - if there is a problem obtaining the node types

    - #### createNodeType

          protected void createNodeType(String name,
                            org.codehaus.jettison.json.JSONObject body,
                            Map<String,NodeType> nodeTypes)
                                 throws Exception

      Throws:
        `Exception`

    - #### getPrimaryType

          protected String getPrimaryType(String key,
                              org.codehaus.jettison.json.JSONObject child)
                                   throws Exception

      Throws:
        `Exception`

    - #### createPropertyDefinition

          protected PropertyDefinition createPropertyDefinition(String defnName,
                                                    org.codehaus.jettison.json.JSONObject body,
                                                    String declaringNodeTypeName,
                                                    Map<String,NodeType> nodeTypes)
                                                         throws Exception

      Throws:
        `Exception`

    - #### createChildNodeDefinition

          protected ChildNodeDefinition createChildNodeDefinition(String defnName,
                                                      org.codehaus.jettison.json.JSONObject body,
                                                      String declaringNodeTypeName,
                                                      Map<String,NodeType> nodeTypes)
                                                           throws Exception

      Throws:
        `Exception`

    - #### valuesFrom

          protected List<String> valuesFrom(org.codehaus.jettison.json.JSONObject properties,
                                String name)
                                     throws Exception

      Throws:
        `Exception`

    - #### valueFrom

          protected boolean valueFrom(org.codehaus.jettison.json.JSONObject properties,
                          String name,
                          boolean defaultValue)
                               throws Exception

      Throws:
        `Exception`

    - #### valueFrom

          protected String valueFrom(org.codehaus.jettison.json.JSONObject properties,
                         String name)
                              throws Exception

      Throws:
        `Exception`

    - #### valueFrom

          protected String valueFrom(org.codehaus.jettison.json.JSONObject properties,
                         String name,
                         String defaultValue)
                              throws Exception

      Throws:
        `Exception`

    - #### typeValueFrom

          protected int typeValueFrom(org.codehaus.jettison.json.JSONObject properties,
                          String name,
                          int defaultType)
                               throws Exception

      Throws:
        `Exception`

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.