Package com.commander4j.javaAbstract

Source Code of com.commander4j.javaAbstract.AbstractConnector

package com.commander4j.javaAbstract;

import java.io.File;

import org.apache.log4j.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Text;

import com.commander4j.connectors.ConnectorXML;
import com.commander4j.interfaces.InboundInterface;
import com.commander4j.interfaces.OutboundInterface;
import com.commander4j.javaInterface.IntefaceConnector;
import com.commander4j.util.Utility;

public abstract class AbstractConnector implements IntefaceConnector{
    private boolean enabled = true;
    private String type = "";
    private String filename = "";
  Logger logger = Logger.getLogger(AbstractConnector.class);

    protected Document data;
   
    private InboundInterface inint;
    private OutboundInterface outint;
    
    public InboundInterface getInboundInterface()
    {
      return inint;
    }
   
    public OutboundInterface getOutboundInterface()
    {
      return outint;
    }
   
    public void processOutboundData(String filename, Document data)
    {
      setData(data);
      connectorSave(filename);
    }
   
    public AbstractConnector(String type,InboundInterface inter)
    {
      this.type = type;
      this.inint = inter;
    }
   
    public AbstractConnector(String type,OutboundInterface outer)
    {
      this.type = type;
      this.outint = outer;
    }
   
  public void setEnabled(boolean enabled)
  {
    this.enabled = enabled;
  }
 
  public boolean getEnabled()
  {
    return this.enabled;
  }

 
  public void processInboundFile(String filename)
  {
    setFilename(filename);
    if (connectorLoad(inint.getInputPath()+File.separator+filename))
    {
      //Save copy of xml data to log directory in xml format.
      ConnectorXML xmllog = new ConnectorXML(this.inint);
      xmllog.setData(getData());
      xmllog.connectorSave(Utility.getLogFilename(filename));
      inint.processConnectorToInterfaceData(filename, getData());
    }
   
   
  }
 
  private void setFilename(String filename)
  {
    this.filename = filename;
  }
 
  public String getFilename()
  {
    return this.filename;
  }

 
  public String getType()
  {
    return type;
  }
 
  public void setType(String type)
  {
    this.type = type;
  }
 
  public void setData(Document data)
  {
    this.data = data;
  }
 
  public Document getData()
  {
    return data;
  }
 
  public Element addElement(Document doc, String name, String value)
  {
    Element temp = (Element) doc.createElement(name);
    Text temp_value = doc.createTextNode(value);
    temp.appendChild(temp_value);
    return temp;
  }
 
}
TOP

Related Classes of com.commander4j.javaAbstract.AbstractConnector

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.