Class AppCtx

All Implemented Interfaces:
ParamContext
Direct Known Subclasses:
PropertyAdapter

public class AppCtx extends HigsonContext
  • Constructor Details

    • AppCtx

      public AppCtx(Property property)
    • AppCtx

      public AppCtx(Property property, boolean checkAdapter)
    • AppCtx

      public AppCtx(Object... args)
  • Method Details

    • with

      public AppCtx with(String key, Property prop)
    • of

      public AppCtx of(Property p)
    • of

      public static AppCtx of(Property p, AppCtx parent)
    • get

      public Object get(String path)
      Description copied from class: HigsonContext

      Tries to resolve given path and return object from the context. If the object is not found at first try, then method is looking for objects by resolving subPath. SubPath is created by stripping given path (between first occurrence of '.' character) into first token and the rest of the path. If stripping was successful and first token is an existing object in context, then algorithm tries to use it as a subContext for the subPath. The more objects exists in depth in context, the longer it might take to resolve them.

      Examples:
      
       HigsonContext ctx = new HigsonContext("policy.status", "AA");
      
       Object s1 = ctx.get("policy.status"); // found object
       Object s2 = ctx.get("policy.info");   // s2 is null here, since there is not object with this path defined in cotext
      
       // Sample with parent context and subContext
       HigsonContext policyCtx = new HigsonContext().set("status", "AA");
       HigsonContext ctx = new HigsonContext().set("policy", policyCtx);
      
       assertThat(ctx.getString("policy.status"), is("AA"));
       assertThat(ctx.getString("policy.info"), nullValue());
       assertThat(ctx.getString("user.name"), nullValue());
       
      Overrides:
      get in class HigsonContext
      Parameters:
      path - to be resolved when looking for object
      Returns:
      object if path was successfully resolved, otherwise null
    • handle

      public Object handle(Object obj)
    • handle

      public static Object handle(Object obj, AppCtx parent)
    • getAppCtx

      public AppCtx getAppCtx(String path)
    • getContext

      public HigsonContext getContext(String path)
    • getCollection

      public Iterable<AppCtx> getCollection(String path)
    • sub

      public AppCtx sub(String path)
    • getAdapterResolver

      public static PropertyAdapterResolver getAdapterResolver()
    • setAdapterResolver

      public static void setAdapterResolver(PropertyAdapterResolver adapterResolver)
    • registerAdapter

      public static void registerAdapter(String type, PropertyAdapterFactory factory)
    • unregisterAdapters

      public static void unregisterAdapters()
    • toString

      public String toString()
      Overrides:
      toString in class HigsonContext