com.h3c.util

## Class ResourceIdUtils

- java.lang.Object
- - com.h3c.util.ResourceIdUtils

-     public class ResourceIdUtils
      extends Object

  Set of utilities for composing and parsing resource identifiers.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static String` | `extract(String rid, String token, String pattern)` Extracts the specified segment from a resource identifier using the given pattern.
    `static String` | `leaf(String rid)` Extracts the leaf portion of the specified resource id, i.e.
    `static String` | `parent(String rid)` Extracts the parent portion of the specified resource id, i.e.
    `static String` | `replace(String value, String token, String rid)` Substitutes the specified value into the supplied rid pattern.

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

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

- - ### Method Detail

    - #### replace

          public static String replace(String value,
                       String token,
                       String rid)

      Substitutes the specified value into the supplied rid pattern.
      Parameters:
        `value` - value to be substituted
        `token` - name of the segment
        `rid` - pattern identifying the resource id path structure
      Returns:
        rid pattern with the given value incorporated into the named path segment

    - #### extract

          public static String extract(String rid,
                       String token,
                       String pattern)

      Extracts the specified segment from a resource identifier using the given pattern.

      Some examples of usage are as follows:

      - extract("/book/I123818172", "isbn", /book/{author}/{isbn}") yields "I123818172"
      - extract("/dev/group/switches/alpha", "gid", "/dev/group/{gid}/{uid}") yields "switches"
      - ...
      Parameters:
        `rid` - resource identifier to be parsed
        `token` - name of the token to be extracted
        `pattern` - pattern identifying segments of interest
      Returns:
        segment of the resource id, identified by the token and the pattern; null if there is no matching token

    - #### leaf

          public static String leaf(String rid)

      Extracts the leaf portion of the specified resource id, i.e. the last URL segment.
      Parameters:
        `rid` - resource id
      Returns:
        leaf segment of the resource id

    - #### parent

          public static String parent(String rid)

      Extracts the parent portion of the specified resource id, i.e. the resource id without the last URL segment.
      Parameters:
        `rid` - resource id
      Returns:
        parent resource id

Copyright © 2014. All Rights Reserved.