Tabnine Logo
ContextItems.getItem
Code IndexAdd Tabnine to your IDE (free)

How to use
getItem
method
in
org.carewebframework.api.context.ContextItems

Best Java code snippets using org.carewebframework.api.context.ContextItems.getItem (Showing top 8 results out of 315)

origin: org.carewebframework/org.carewebframework.api.core

/**
 * Returns a date item associated with the specified item name.
 *
 * @param itemName Item name
 * @return Date value
 */
public Date getDate(String itemName) {
  try {
    return DateUtil.parseDate(getItem(itemName));
  } catch (Exception e) {
    return null;
  }
}
origin: org.carewebframework/org.carewebframework.api

/**
 * Returns a date item associated with the specified item name.
 * 
 * @param itemName Item name
 * @return Date value
 */
public Date getDate(String itemName) {
  try {
    return DateUtil.parseDate(getItem(itemName));
  } catch (Exception e) {
    return null;
  }
}

origin: org.carewebframework/org.carewebframework.api

/**
 * Returns a map consisting of suffixes of context items that match the specified prefix.
 * 
 * @param prefix Item name less any suffix.
 * @param firstOnly If true, only the first match is returned. Otherwise, all matches are
 *            returned.
 * @return Map of suffixes whose prefix matches the specified value. The value of each map entry
 *         is the value of the original context item.
 */
private Map<String, String> getSuffixes(String prefix, Boolean firstOnly) {
  HashMap<String, String> matches = new HashMap<String, String>();
  prefix = normalizePrefix(prefix);
  int i = prefix.length();
  
  for (String itemName : index.keySet()) {
    if (itemName.startsWith(prefix)) {
      String suffix = lookupItemName(itemName, false).substring(i);
      matches.put(suffix, getItem(itemName));
      
      if (firstOnly) {
        break;
      }
    }
  }
  
  return matches;
}

origin: org.carewebframework/org.carewebframework.api.core

/**
 * Returns a map consisting of suffixes of context items that match the specified prefix.
 *
 * @param prefix Item name less any suffix.
 * @param firstOnly If true, only the first match is returned. Otherwise, all matches are
 *            returned.
 * @return Map of suffixes whose prefix matches the specified value. The value of each map entry
 *         is the value of the original context item.
 */
private Map<String, String> getSuffixes(String prefix, Boolean firstOnly) {
  HashMap<String, String> matches = new HashMap<>();
  prefix = normalizePrefix(prefix);
  int i = prefix.length();
  for (String itemName : index.keySet()) {
    if (itemName.startsWith(prefix)) {
      String suffix = lookupItemName(itemName, false).substring(i);
      matches.put(suffix, getItem(itemName));
      if (firstOnly) {
        break;
      }
    }
  }
  return matches;
}
origin: org.carewebframework/org.carewebframework.api

  /**
   * Unmarshals the marshaled context. Performs digital signature verification, then returns the
   * unmarshaled context items.
   * 
   * @param marshaledContext Marshaled context
   * @param authSignature If set, the digital signature is verified.
   * @return The unmarshaled context.
   * @throws Exception Unspecified exception.
   */
  public ContextItems unmarshal(String marshaledContext, String authSignature) throws Exception {
    ContextItems contextItems = new ContextItems();
    contextItems.addItems(marshaledContext);
    String whichKey = contextItems.getItem(PROPNAME_KEY);
    String timestamp = contextItems.getItem(PROPNAME_TIME);
    
    if (authSignature != null && !signer.verify(authSignature, marshaledContext, timestamp, whichKey)) {
      throw new MarshalException("Invalid digital signature");
    }
    
    return contextItems;
  }
}
origin: org.carewebframework/org.carewebframework.api.core

  /**
   * Unmarshals the marshaled context. Performs digital signature verification, then returns the
   * unmarshaled context items.
   * 
   * @param marshaledContext Marshaled context
   * @param authSignature If set, the digital signature is verified.
   * @return The unmarshaled context.
   * @throws Exception Unspecified exception.
   */
  public ContextItems unmarshal(String marshaledContext, String authSignature) throws Exception {
    ContextItems contextItems = new ContextItems();
    contextItems.addItems(marshaledContext);
    String whichKey = contextItems.getItem(PROPNAME_KEY);
    String timestamp = contextItems.getItem(PROPNAME_TIME);
    
    if (authSignature != null && !signer.verify(authSignature, marshaledContext, timestamp, whichKey)) {
      throw new MarshalException("Invalid digital signature");
    }
    
    return contextItems;
  }
}
origin: org.carewebframework/org.carewebframework.api

/**
 * Returns an object of the specified class. The class must have an associated context
 * serializer registered.
 * 
 * @param itemName Item name
 * @param clazz Class of item to be returned.
 * @return Deserialized item of specified class.
 * @throws ContextException If no context serializer found.
 */
@SuppressWarnings("unchecked")
public <T> T getItem(String itemName, Class<T> clazz) throws ContextException {
  String item = getItem(itemName);
  
  if (item == null || item.isEmpty()) {
    return null;
  }
  
  IContextSerializer<?> contextSerializer = ContextSerializerRegistry.getInstance().get(clazz);
  
  if (contextSerializer == null) {
    throw new ContextException("No serializer found for type " + clazz.getName());
  }
  
  return (T) contextSerializer.deserialize(item);
}

origin: org.carewebframework/org.carewebframework.api.core

/**
 * Returns an object of the specified class. The class must have an associated context
 * serializer registered.
 *
 * @param <T> The item's class.
 * @param itemName Item name
 * @param clazz Class of item to be returned.
 * @return Deserialized item of specified class.
 * @throws ContextException If no context serializer found.
 */
@SuppressWarnings("unchecked")
public <T> T getItem(String itemName, Class<T> clazz) throws ContextException {
  String item = getItem(itemName);
  if (item == null || item.isEmpty()) {
    return null;
  }
  ISerializer<?> contextSerializer = ContextSerializerRegistry.getInstance().get(clazz);
  if (contextSerializer == null) {
    throw new ContextException("No serializer found for type " + clazz.getName());
  }
  return (T) contextSerializer.deserialize(item);
}
org.carewebframework.api.contextContextItemsgetItem

Javadoc

Retrieves a context item by name.

Popular methods of ContextItems

  • setItem
    Sets a context item value, qualified with the specified suffix.
  • <init>
  • addItems
    Adds context items to this set.
  • clear
    Clear all context items and the index.
  • getItemNames
    Returns a set of all item names.
  • getSuffixes
    Returns a map consisting of suffixes of context items that match the specified prefix.
  • lookupItemName
    Performs a case-insensitive lookup of the item name in the index.
  • normalizePrefix
    Normalizes a prefix by appending a "." if necessary and converting to lower case.
  • toString
    Serializes the context item set to a string.

Popular in Java

  • Parsing JSON documents to java classes using gson
  • setScale (BigDecimal)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • onRequestPermissionsResult (Fragment)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • ImageIO (javax.imageio)
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now