/**
  * Returns the {@link RHSHistory history} of the types that have been selected most recently as
  * right hand sides for the given type.
  *
  * @param lhs the fully qualified type name of an expected type for which right hand sides are
  *     requested, or <code>null</code>
  * @return the right hand side history for the given type
  */
 public RHSHistory getHistory(String lhs) {
   MRUSet<String> rhsCache = fLHSCache.get(lhs);
   if (rhsCache != null) {
     int count = rhsCache.size();
     LinkedHashMap<String, Integer> history =
         new LinkedHashMap<String, Integer>((int) (count / 0.75));
     int rank = 1;
     for (Iterator<String> it = rhsCache.iterator(); it.hasNext(); rank++) {
       String type = it.next();
       history.put(type, new Integer(rank));
     }
     return new RHSHistory(history);
   }
   return EMPTY_HISTORY;
 }
    public void store(ContentAssistHistory history, StreamResult result) throws CoreException {
      try {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        Document document = builder.newDocument();

        Element rootElement = document.createElement(NODE_ROOT);
        rootElement.setAttribute(ATTRIBUTE_MAX_LHS, Integer.toString(history.fMaxLHS));
        rootElement.setAttribute(ATTRIBUTE_MAX_RHS, Integer.toString(history.fMaxRHS));
        document.appendChild(rootElement);

        for (Iterator<String> leftHandSides = history.fLHSCache.keySet().iterator();
            leftHandSides.hasNext(); ) {
          String lhs = leftHandSides.next();
          Element lhsElement = document.createElement(NODE_LHS);
          lhsElement.setAttribute(ATTRIBUTE_NAME, lhs);
          rootElement.appendChild(lhsElement);

          MRUSet<String> rightHandSides = history.fLHSCache.get(lhs);
          for (Iterator<String> rhsIterator = rightHandSides.iterator(); rhsIterator.hasNext(); ) {
            String rhs = rhsIterator.next();
            Element rhsElement = document.createElement(NODE_RHS);
            rhsElement.setAttribute(ATTRIBUTE_NAME, rhs);
            lhsElement.appendChild(rhsElement);
          }
        }

        Transformer transformer = TransformerFactory.newInstance().newTransformer();
        transformer.setOutputProperty(OutputKeys.METHOD, "xml"); // $NON-NLS-1$
        transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); // $NON-NLS-1$
        transformer.setOutputProperty(OutputKeys.INDENT, "no"); // $NON-NLS-1$
        DOMSource source = new DOMSource(document);

        transformer.transform(source, result);
      } catch (TransformerException e) {
        throw createException(e, JavaTextMessages.ContentAssistHistory_serialize_error);
      } catch (ParserConfigurationException e) {
        throw createException(e, JavaTextMessages.ContentAssistHistory_serialize_error);
      }
    }