Package org.apache.juddi.handler

Source Code of org.apache.juddi.handler.InstanceDetailsHandler

/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.juddi.handler;

import java.util.Vector;

import org.apache.juddi.datatype.Description;
import org.apache.juddi.datatype.OverviewDoc;
import org.apache.juddi.datatype.RegistryObject;
import org.apache.juddi.datatype.binding.InstanceDetails;
import org.apache.juddi.datatype.binding.InstanceParms;
import org.apache.juddi.util.xml.XMLUtils;
import org.w3c.dom.Element;

/**
* "Knows about the creation and populating of InstanceDetails objects.
* Returns InstanceDetails."
*
* @author Steve Viens (sviens@apache.org)
*/
public class InstanceDetailsHandler extends AbstractHandler
{
  public static final String TAG_NAME = "instanceDetails";

  private HandlerMaker maker = null;

  protected InstanceDetailsHandler(HandlerMaker maker)
  {
    this.maker = maker;
  }

  public RegistryObject unmarshal(Element element)
  {
    InstanceDetails obj = new InstanceDetails();
    Vector nodeList = null;
    AbstractHandler handler = null;

    // Attributes
    // {none}

    // Text Node Value
    // {none}

    // Child Elements
    nodeList = XMLUtils.getChildElementsByTagName(element,DescriptionHandler.TAG_NAME);
    for (int i=0; i<nodeList.size(); i++)
    {
      handler = maker.lookup(DescriptionHandler.TAG_NAME);
      Description descr = (Description)handler.unmarshal((Element)nodeList.elementAt(i));
      if (descr != null)
        obj.addDescription(descr);
    }

    nodeList = XMLUtils.getChildElementsByTagName(element,OverviewDocHandler.TAG_NAME);
    if (nodeList.size() > 0)
    {
      handler = maker.lookup(OverviewDocHandler.TAG_NAME);
      obj.setOverviewDoc((OverviewDoc)handler.unmarshal((Element)nodeList.elementAt(0)));
    }

    nodeList = XMLUtils.getChildElementsByTagName(element,InstanceParmsHandler.TAG_NAME);
    if (nodeList.size() > 0)
    {
      handler = maker.lookup(InstanceParmsHandler.TAG_NAME);
      obj.setInstanceParms((InstanceParms)handler.unmarshal((Element)nodeList.elementAt(0)));
    }

    return obj;
  }

  public void marshal(RegistryObject object,Element parent)
  {
    InstanceDetails instDet = (InstanceDetails)object;
    String generic = getGeneric(null);
    String namespace = getUDDINamespace(generic);
    Element element = parent.getOwnerDocument().createElementNS(namespace,TAG_NAME);
    AbstractHandler handler = null;

  Vector descrVector = instDet.getDescriptionVector();
  if ((descrVector!=null) && (descrVector.size() > 0))
  {
    handler = maker.lookup(DescriptionHandler.TAG_NAME);
    for (int i=0; i < descrVector.size(); i++)
    handler.marshal((Description)descrVector.elementAt(i),element);
  }

    OverviewDoc overDoc = instDet.getOverviewDoc();
    if (overDoc != null)
    {
      handler = maker.lookup(OverviewDocHandler.TAG_NAME);
      handler.marshal(overDoc,element);
    }

  InstanceParms instanceParms = instDet.getInstanceParms();
  if (instanceParms != null)
  {
    handler = maker.lookup(InstanceParmsHandler.TAG_NAME);
    handler.marshal(instanceParms,element);
  }

    parent.appendChild(element);
  }


  /***************************************************************************/
  /***************************** TEST DRIVER *********************************/
  /***************************************************************************/


  public static void main(String args[])
    throws Exception
  {
  }
}
TOP

Related Classes of org.apache.juddi.handler.InstanceDetailsHandler

TOP
Copyright © 2018 www.massapi.com. 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.