Package org.bifrost.xmlio.config

Examples of org.bifrost.xmlio.config.ObjectMap


        throw new SAXException(EX_CREATE_OBJECT + objectName + getLocation());
    }

    String methodName = attributeName;

    ObjectMap omap = config.getObjectMapByName(objectName);
    if (omap == null)
      omap = config.getObjectMapByName(nameWithoutPackage(objectName));
    if (omap == null)
    {
      omap = ObjectMap.createFromClass(object.getClass());
      config.addObjectMap(omap);
    }
   
    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);
View Full Code Here


    }

    // 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();
View Full Code Here

   * Set up some simple property mappings for a specific object.
   *
   */
  private void configSimpleTestFromObject()
  {
    ObjectMap oMap = new ObjectMap();
    oMap.setName("TestHelperSimple");
    oMap.setXmlName("TestHelperSimple");
    PropertyMap map = new PropertyMap();
    map.setPropertyXmlName("theString");
    map.setPropertyName("string");
    map.setPropertyType(String.class);
    oMap.addPropertyMap(map);
   
    map = new PropertyMap();
    map.setPropertyXmlName("theNumber");
    map.setPropertyName("number");
    map.setPropertyType(Long.class);
    oMap.addPropertyMap(map);
    config.addObjectMap(oMap);
  }
View Full Code Here

  }
 
  public void testSimpleCreateFromClass()
  {
    assertNull(ObjectMap.createFromClass(null));
    ObjectMap om = ObjectMap.createFromClass(TestHelperObjectMapEmpty.class);
    assertNotNull(om);
    String thisName =
      nameWithoutPackage(TestHelperObjectMapEmpty.class.getName());
    assertEquals(thisName, om.getName());
    assertEquals(thisName, om.getXmlName());
    assertNotNull(om.getPropertyMap());
    assertEquals(om.getPropertyMap().size(), 0);
  }
View Full Code Here

  }
 
  public void testCreateFromClass()
  {
    assertNull(ObjectMap.createFromClass(null));
    ObjectMap om = ObjectMap.createFromClass(TestHelperObjectMap.class);
    assertNotNull(om);
    String thisName = nameWithoutPackage(TestHelperObjectMap.class.getName());
    assertEquals(thisName, om.getName());
    assertEquals(thisName, om.getXmlName());
    assertNotNull(om.getPropertyMap());
    assertNull(om.getPropertyMapFromAlias("fooBar"));
    assertNotNull(om.getPropertyMapFromAlias("id"));
    assertNotNull(om.getPropertyMapFromAlias("name"));
    assertNotNull(om.getPropertyMapFromAlias("age"));
    assertNotNull(om.getPropertyMapFromAlias("birthday"));
  }
View Full Code Here

  }

  public void testPropertyMap()
  {
    assertNull(ObjectMap.createFromClass(null));
    ObjectMap om = ObjectMap.createFromClass(TestHelperObjectMap.class);
    assertNotNull(om);
    assertNotNull(om.getPropertyMapFromAlias("id"));
    PropertyMap pm = om.getPropertyMapFromAlias("id");
    assertTrue("id".equals(pm.getPropertyName()));
    assertTrue("id".equals(pm.getPropertyXmlName()));
    assertTrue("long".equals(pm.getPropertyType().getName()));
  }
View Full Code Here

   
    String fqClassName = object.getClass().getName();
    String className = StringHelper.classNameWithoutPackage(fqClassName);

    // Look up the object via it's short name
    ObjectMap oMap = config.getObjectMapByName(className);
    // If not found, look for it via it's fully qualified name
    if (oMap == null)
      oMap = config.getObjectMapByName(fqClassName);
    // If not found, create a mapping from the object's class
    if (oMap == null)
      oMap = config.addClassAsMappedObject(object.getClass());
   
    if (oMap == null)
      throw new XmlException ("Cannot find nor create definition for " + className);

    className = oMap.getXmlName();
    if (dashedNames == true)
      className = StringHelper.capitalsToDashes(className);
   
    logger.fine("Writing object " + oMap.getName() + " as <" + className + ">");

    try
    {
      if (beautify == true)
        outputIndent(indentLevel, writer);
View Full Code Here

TOP

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

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.