Package net.sourceforge.urlrewriter4j.core.utilities

Examples of net.sourceforge.urlrewriter4j.core.utilities.StringDictionnary


    pConfig.getErrorHandlers().put(Integer.parseInt(oCodeNode.getNodeValue()), oHandler);
  }
 
  private void readMapping(Node pNode, RewriterConfiguration pConfig) throws ConfigurationException {
    Node oNameNode = ParserHelper.getAttribute(pNode, Constants.ATTR_NAME, true);
    StringDictionnary oMap = new StringDictionnary();
    for (int i = 0; i < pNode.getChildNodes().getLength(); i++) {
      Node oNode = pNode.getChildNodes().item(i);
      if (Constants.ELEMENT_MAP.equals(oNode.getNodeName()) && oNode.getNodeType() == Node.ELEMENT_NODE) {
        Node oFromValueNode = ParserHelper.getAttribute(oNode, Constants.ATTR_FROM, true);
        Node oToValueNode =  ParserHelper.getAttribute(oNode, Constants.ATTR_TO, true);
        oMap.put(oFromValueNode.getNodeValue(), oToValueNode.getNodeValue());
      } else if (oNode.getNodeType() != Node.TEXT_NODE){
        throw new ConfigurationException(String.format(Messages.ELEMENT_NOTALLOWED, oNode.getNodeName()));
      }
    }
    pConfig.getTransformFactory().addTransform(new StaticMappingTransform(oNameNode.getNodeValue(), oMap));
View Full Code Here


   
    public void testStaticMappingTransform()
    {
      // Note that this is case insensitive.
      StringDictionnary oMap = new StringDictionnary();
      for (char c = 'a'; c <= 'z'; c++)
      {
        oMap.put(Character.toString(c), "" + ((int)c));
      }
      IRewriteTransform oTx = new StaticMappingTransform("name", oMap);
      assertEquals("99", oTx.applyTransform("c"));
      assertEquals("97", oTx.applyTransform("a"));
      assertEquals("98", oTx.applyTransform("B"));
View Full Code Here

TOP

Related Classes of net.sourceforge.urlrewriter4j.core.utilities.StringDictionnary

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.