Package org.bifrost.xmlio.config

Examples of org.bifrost.xmlio.config.PropertyMap


    config.addConverter(dconv);
    TimestampConverter tconv = new TimestampConverter("yyyy-MM-dd HH:mm");
    config.addConverter(tconv);
   
    List plist = new LinkedList();
    PropertyMap pmap = new PropertyMap("created");
    plist.add(pmap);
    pmap = new PropertyMap("startDate");
    plist.add(pmap);
    pmap = new PropertyMap("startTime");
    dconv = new DateConverter("HH:mm:ss");
    pmap.setConverter(dconv);
    plist.add(pmap);
    pmap = new PropertyMap("endTime");
    pmap.setConverter(dconv);
    plist.add(pmap);
    pmap = new PropertyMap("calendar");
    pmap.setConverter(new GregorianCalendarConverter());
    plist.add(pmap);
    ObjectMap omap = new ObjectMap("TestHelperDate", "TestHelperDate", plist);
    config.addObjectMap(omap);
   
    CharArrayWriter output = new CharArrayWriter();
View Full Code Here


  public void testMixedAttributes()
  {
    XmlIOConfig config = XmlIOConfig.getInstance();
    // Set up mapping
    ObjectMap oMap = ObjectMap.createFromClass(TestHelperSimple.class);
    PropertyMap pMap = oMap.getPropertyMapFromName("number");
    pMap.setWriteAsAttribute(true);
    config.addObjectMap(oMap);

    CharArrayWriter output = new CharArrayWriter();
    assertNotNull(output);
    TestHelperSimple simple = new TestHelperSimple();
View Full Code Here

  {
//    String configString = createXml(TEST_OBJECT_PROPERTY_MAPPING);
    XmlIOConfig config = XmlIOConfig.getInstance();
    // Set up mapping
    List list = new LinkedList();
    list.add(new PropertyMap("a", "string"));
    list.add(new PropertyMap("b", "number"));
    ObjectMap oMap = new ObjectMap("obj", "TestHelperSimple", list);
    config.addObjectMap(oMap);
    list = new LinkedList();
    list.add(new PropertyMap("obj", "testHelperSimple"));
    oMap = new ObjectMap("TestHelperComplex", "TestHelperComplex", list);
    config.addObjectMap(oMap);
    // Create the object graph
    TestHelperComplex helper = new TestHelperComplex();
    assertNotNull(helper);
View Full Code Here

  {
    String configString = createXml(TEST_OBJECT_PROPERTY_MAPPING);
    XmlIOConfig config = XmlIOConfig.getInstance();
    // Set up mapping
    List list = new LinkedList();
    list.add(new PropertyMap("a", "string"));
    list.add(new PropertyMap("b", "number"));
    ObjectMap oMap = new ObjectMap("obj", "TestHelperSimple", list);
    config.addObjectMap(oMap);
    list = new LinkedList();
    list.add(new PropertyMap("obj", "TestHelperSimple"));
    oMap = new ObjectMap("TestHelperComplex", "TestHelperComplex", list);
    config.addObjectMap(oMap);
    InputStream reader = new ByteArrayInputStream(configString.getBytes());
    XmlReader xmlReader = null;
    try
View Full Code Here

  {
    String configString = createXml(TEST_OBJECT_MAPPING);
    XmlIOConfig config = XmlIOConfig.getInstance();
    // Set up mapping
    List list = new LinkedList();
    list.add(new PropertyMap("obj", "TestHelperSimple"));
    ObjectMap oMap = new ObjectMap("TestHelperComplex", "TestHelperComplex", list);
    config.addObjectMap(oMap);
    InputStream reader = new ByteArrayInputStream(configString.getBytes());
    XmlReader xmlReader = null;
    try
View Full Code Here

  {
    String configString = createXml(TEST_PROPERTY_MAPPING);
    XmlIOConfig config = XmlIOConfig.getInstance();
    // Set up mapping
    List list = new LinkedList();
    list.add(new PropertyMap("a", "string"));
    list.add(new PropertyMap("b", "number"));
    ObjectMap oMap = new ObjectMap("TestHelperSimple", "TestHelperSimple", list);
    config.addObjectMap(oMap);
    InputStream reader = new ByteArrayInputStream(configString.getBytes());
    XmlReader xmlReader = null;
    try
View Full Code Here

  public void testGlobalPropertyMapping()
  {
    String configString = createXml(TEST_PROPERTY_MAPPING);
    XmlIOConfig config = XmlIOConfig.getInstance();
    // Set up mapping
    config.addPropertyMap(new PropertyMap("a", "string"));
    config.addPropertyMap(new PropertyMap("b", "number"));
    InputStream reader = new ByteArrayInputStream(configString.getBytes());
    XmlReader xmlReader = null;
    try
    {
      xmlReader = new XmlReader(reader, "org.bifrost.xmlio.test.helpers");
View Full Code Here

    config.addConverter(dconv);
    TimestampConverter tconv = new TimestampConverter("yyyy-MM-dd HH:mm");
    config.addConverter(tconv);

    List plist = new LinkedList();
    PropertyMap pmap = new PropertyMap("created");
    plist.add(pmap);
    pmap = new PropertyMap("startDate");
    plist.add(pmap);
    pmap = new PropertyMap("startTime");
    dconv = new DateConverter("HH:mm:ss");
    pmap.setConverter(dconv);
    plist.add(pmap);
    pmap = new PropertyMap("endTime");
    pmap.setConverter(dconv);
    plist.add(pmap);
    ObjectMap omap = new ObjectMap("TestHelperDate", "TestHelperDate", plist);
    config.addObjectMap(omap);

    try
View Full Code Here

    }
   
    Method method = null;
    boolean global = false;
   
    PropertyMap pmap = omap.getPropertyMapFromName(methodName);
    if (pmap == null)
      pmap = omap.getPropertyMapFromName(lowerCaseFirst(methodName));
    if (pmap == null)
      pmap = omap.getPropertyMapFromName(capitalizeFirst(methodName));

    // Check to see if it's globally defined
    if (pmap == null)
    {
      pmap = config.getPropertyMapByName(methodName);
      if (pmap == null)
        pmap = config.getPropertyMapByName(lowerCaseFirst(methodName));
      if (pmap == null)
        pmap = config.getPropertyMapByName(capitalizeFirst(methodName));
      if (pmap != null)
        global = true;
    }
   
    StringBuffer trace = new StringBuffer(methodName);
   
    if (pmap == null)
    {
      Object thisObject = instantiateObject(methodName);
      Class superClass = null;
      if (thisObject != null)
        superClass = thisObject.getClass().getSuperclass();

      while (superClass != null && pmap == null)
      {
        methodName = nameWithoutPackage(superClass.getName());
        trace.append(" or ");
        trace.append(methodName);
        pmap = omap.getPropertyMapFromName(methodName);
        if (pmap == null)
          pmap = omap.getPropertyMapFromName(lowerCaseFirst(methodName));

        // Check to see if it's globally defined
        if (pmap == null)
        {
          pmap = config.getPropertyMapByName(methodName);
          if (pmap == null)
            pmap = config.getPropertyMapByName(capitalizeFirst(methodName));
          if (pmap != null)
            global = true;
        }

        superClass = superClass.getSuperclass();
      }
    }

    if (pmap == null)
    {
      String error = EX_SETTER_NAME +" for " + trace.toString() + " in " + objectName;
      logger.fine(error);
      throw new SAXException(error);
    }
    if (pmap != null)
      method = pmap.getSetter();

    // If the setter method is undefined for this property map, then the
    // property map was probably added to config programmatically or through
    // a config file, rather than being generated from a class.
    if (method == null && pmap != null)
    {
      // Guess what the setter might be
      method = pmap.guessSetter(object);
      // And cache the method if it's not a global property map
      if (method != null && global == false)
        pmap.setSetter(method);
    }
   
    try
    {
      propertyHelper.setAttribute(pmap, object, method, value);
View Full Code Here

   
    String result = alias;
    // Check to see is this attribute has a mapping.
    if (config.getPropertyMapByAlias(alias) != null)
    {
      PropertyMap map = config.getPropertyMapByAlias(alias);
      if (map != null && map.getPropertyName() != null)
      {
        result = map.getPropertyName();
        logger.fine("Found global property map for " + alias);
      }
    }

    // See if this property is actually an object in the mapping
    if (config.getObjectMapByAlias(alias) != null)
    {
      ObjectMap map = config.getObjectMapByAlias(alias);
      logger.fine("Found map for " + alias + " as an object (" +
          map.getName() + ")");
      result = map.getName();
      return result;
    }

    if (classAlias == null)
    {
      logger.fine("No class alias name passed");
      return result;
    }

    // See if the current object is in the mapping and if this property is
    // also mapped...
    if (config.getObjectMapByAlias(classAlias) != null)
    {
      ObjectMap map = config.getObjectMapByAlias(classAlias);
      if (map != null && map.getPropertyMapFromAlias(alias) != null)
      {
        PropertyMap pMap = map.getPropertyMapFromAlias(alias);
        if (pMap.getPropertyName() != null)
        {
          logger.fine("Found property map for " + alias +
              " as part of map for " + classAlias);
          result = pMap.getPropertyName();
        }
      } // end property map found
    } // end object map found
   
    if (result == null || result.length() == 0)
View Full Code Here

TOP

Related Classes of org.bifrost.xmlio.config.PropertyMap

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.