Codota Logo
ContextItems
Code IndexAdd Codota to your IDE (free)

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

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

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
StringBuilder s =
  • Codota Iconnew StringBuilder()
  • Codota Iconnew StringBuilder(32)
  • Codota IconString str;new StringBuilder(str)
  • Smart code suggestions by Codota
}
origin: org.carewebframework/org.carewebframework.api.core

/**
 * Saves a date item object as a context item.
 *
 * @param itemName Item name
 * @param date Date value
 */
public void setDate(String itemName, Date date) {
  if (date == null) {
    setItem(itemName, null);
  } else {
    setItem(itemName, DateUtil.toHL7(date));
  }
}
origin: org.carewebframework/org.carewebframework.api.core

/**
 * Returns the marshaled context representing the state of all shared contexts.
 *
 * @return A ContextItems object representing the current state of all shared contexts.
 */
public ContextItems getMarshaledContext() {
  ContextItems marshaledContext = new ContextItems();
  for (IManagedContext<?> managedContext : managedContexts) {
    marshaledContext.addItems(managedContext.getContextItems(false));
  }
  return marshaledContext;
}
origin: org.carewebframework/org.carewebframework.api.core

/**
 * Remove all context items for the specified subject.
 *
 * @param subject Prefix whose items are to be removed.
 */
public void removeSubject(String subject) {
  String prefix = normalizePrefix(subject);
  for (String suffix : getSuffixes(prefix).keySet()) {
    setItem(prefix + suffix, null);
  }
}
origin: org.carewebframework/org.carewebframework.api.core

/**
 * Marshals the current context as a string.
 * 
 * @param contextItems The context items to marshal.
 * @return The marshaled context.
 */
public String marshal(ContextItems contextItems) {
  SimpleDateFormat timestampFormat = new SimpleDateFormat("yyyyMMddHHmmssz");
  contextItems.setItem(PROPNAME_TIME, timestampFormat.format(new Date()));
  contextItems.setItem(PROPNAME_KEY, signer.getKeyName());
  return contextItems.toString();
}

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

/**
 * 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

/**
 * Performs a case-insensitive lookup of the item name + suffix in the index.
 * 
 * @param itemName Item name
 * @param suffix Item suffix
 * @param autoAdd If true and item name not in index, add it.
 * @return Item name with suffix as stored internally
 */
private String lookupItemName(String itemName, String suffix, boolean autoAdd) {
  return lookupItemName(itemName + "." + suffix, autoAdd);
}

origin: org.carewebframework/org.carewebframework.api

/**
 * Initializes one or all managed contexts to their default state.
 * 
 * @param item Managed context to initialize or, if null, initializes all managed contexts.
 * @return True if the operation was successful.
 */
public boolean init(IManagedContext item) {
  contextItems.clear();
  boolean result = true;
  
  if (ccowIsActive()) {
    contextItems.addItems(ccowContextManager.getCCOWContext());
  }
  
  if (item != null) {
    result = initItem(item);
  } else {
    for (IManagedContext managedContext : managedContexts) {
      result &= initItem(managedContext);
    }
  }
  return result;
}

origin: org.carewebframework/org.carewebframework.api

/**
 * Returns a map consisting of all suffixes of context items that match the specified prefix.
 * 
 * @param prefix Item name less any suffix.
 * @return Map of all suffixes whose prefix matches the specified value. The value of each map
 *         entry is the value of the original context item.
 */
public Map<String, String> getSuffixes(String prefix) {
  return getSuffixes(prefix, false);
}

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.core

/**
 * @see org.carewebframework.api.context.IManagedContext#getContextItems(boolean)
 */
@Override
public ContextItems getContextItems(boolean pending) {
  contextItems.clear();
  DomainClass domainObject = getContextObject(pending);
  return domainObject == null ? contextItems : toCCOWContext(domainObject);
}

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

/**
 * Adds context items to this set.
 *
 * @param contextItems Context items to add.
 */
public void addItems(ContextItems contextItems) {
  addItems(contextItems.items);
}
origin: org.carewebframework/org.carewebframework.api.core

/**
 * Returns true if the CCOW context contains context settings pertaining to the named subject.
 *
 * @param subject Name of the CCOW subject
 * @return True if settings for the specified subject were found.
 */
private boolean hasSubject(String subject) {
  boolean result = false;
  String s = subject + ".";
  int c = s.length();
  for (String propName : contextItems.getItemNames()) {
    result = s.equalsIgnoreCase(propName.substring(0, c));
    if (result) {
      break;
    }
  }
  return result;
}
origin: org.carewebframework/org.carewebframework.api

/**
 * Marshals the current context as a string.
 * 
 * @param contextItems The context items to marshal.
 * @return The marshaled context.
 */
public String marshal(ContextItems contextItems) {
  SimpleDateFormat timestampFormat = new SimpleDateFormat("yyyyMMddHHmmssz");
  contextItems.setItem(PROPNAME_TIME, timestampFormat.format(new Date()));
  contextItems.setItem(PROPNAME_KEY, signer.getKeyName());
  return contextItems.toString();
}

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.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.core

/**
 * Performs a case-insensitive lookup of the item name + suffix in the index.
 *
 * @param itemName Item name
 * @param suffix Item suffix
 * @param autoAdd If true and item name not in index, add it.
 * @return Item name with suffix as stored internally
 */
private String lookupItemName(String itemName, String suffix, boolean autoAdd) {
  return lookupItemName(itemName + "." + suffix, autoAdd);
}
origin: org.carewebframework/org.carewebframework.api.core

/**
 * Initializes one or all managed contexts to their default state.
 *
 * @param item Managed context to initialize or, if null, initializes all managed contexts.
 * @param callback Callback to report subscriber responses.
 */
public void init(IManagedContext<?> item, ISurveyCallback callback) {
  contextItems.clear();
  if (ccowIsActive()) {
    contextItems.addItems(ccowContextManager.getCCOWContext());
  }
  if (item != null) {
    initItem(item, callback);
  } else {
    SurveyResponse response = new SurveyResponse();
    initItem(managedContexts.iterator(), response, callback);
  }
}
origin: org.carewebframework/org.carewebframework.api.core

/**
 * Returns a map consisting of all suffixes of context items that match the specified prefix.
 *
 * @param prefix Item name less any suffix.
 * @return Map of all suffixes whose prefix matches the specified value. The value of each map
 *         entry is the value of the original context item.
 */
public Map<String, String> getSuffixes(String prefix) {
  return getSuffixes(prefix, false);
}
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;
  }
}

org.carewebframework.api.contextContextItems

Javadoc

Encapsulates a set of context items. Internally, these are stored in a hash map with a separate index to allow case-insensitive lookup.

Most used methods

  • 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.
  • getItem
    Retrieves a context item qualified by a suffix.
  • 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
  • getApplicationContext (Context)
  • compareTo (BigDecimal)
    Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in val
  • onCreateOptionsMenu (Activity)
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • InetAddress (java.net)
    This class represents an Internet Protocol (IP) address. An IP address is either a 32-bit or 128-bit
  • Locale (java.util)
    A Locale object represents a specific geographical, political, or cultural region. An operation that
  • JTextField (javax.swing)
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now