<commit_before>/*
 * Copyright (c) 2006 Digital Bazaar, Inc.  All rights reserved.
 */
package com.db.net.soap;

import java.util.Iterator;

import com.db.logging.Logger;
import com.db.logging.LoggerManager;
import com.db.xml.XmlElement;

/**
 * A RpcSoapEnvelope is a SoapEnvelope that holds either a SoapOperation
 * or a SoapFault. It is specifically used to perform remote procedure calls
 * (via SoapOperations) over SOAP (Simple Object Access Protocol).
 * 
 * @author <NAME>
 */
public class RpcSoapEnvelope extends SoapEnvelope
{
   /**
    * The SoapOperation this envelope contains, if any.
    */
   protected SoapOperation mSoapOperation;
   
   /**
    * The SoapFault this envelope contains, if any.
    */
   protected SoapFault mSoapFault;
   
   /**
    * Creates a new empty RpcSoapEnvelope.
    */
   public RpcSoapEnvelope()
   {
      // no operation or fault by default
      mSoapOperation = null;
      mSoapFault = null;
   }
   
   /**
    * This method takes options that are used to configure
    * how to convert to and from xml.
    *
    * @param options the configuration options.
    * 
    * @return true if options successfully set, false if not.    
    */
   public boolean setXmlSerializerOptions(int options)
   {
      // no options
      return false;
   }

   /**
    * This method gets the options that are used to configure
    * how to convert to and from xml.
    *
    * @return the configuration options.
    */
   public int getXmlSerializerOptions()
   {
      // no options
      return 0;
   }
   
   /**
    * Returns the root tag name for this serializer.
    * 
    * @return the root tag name for this serializer.
    */
   public String getRootTag()   
   {
      // this is according to the soap envelope schema
      return "Envelope";
   }
   
   /**
    * Converts this object from an XmlElement.
    *
    * @param element the XmlElement to convert from.
    * 
    * @return true if successful, false otherwise.
    */
   public boolean convertFromXmlElement(XmlElement element)   
   {
      boolean rval = false;
      
      // clear soap operation and soap fault
      mSoapOperation = null;
      mSoapFault = null;
      
      // create a new soap operation and soap fault
      SoapOperation operation = new SoapOperation();
      SoapFault fault = new SoapFault();
      
      // convert the base class soap envelope
      if(super.convertFromXmlElement(element))
      {
         // look for a soap fault or soap operation in the body content of
         // the envelope
         boolean foundFault = false;
         boolean foundOperation = false;
         for(Iterator i = getBodyContents().iterator();
             i.hasNext() && !foundOperation && !foundFault;)
         {
            XmlElement contentElement = (XmlElement)i.next();
            
            // try to convert a fault
            if(contentElement.getRootTag().equals(fault.getRootTag()))
            {
               foundFault = fault.convertFromXmlElement(contentElement);
            }
            else
            {
               // try to convert an operation
               foundOperation = operation.convertFromXmlElement(contentElement);
            }
         }
         
         // determine if a fault or an operation was found
         if(foundFault)
         {
            // set soap fault
            setSoapFault(fault);
            rval = true;
         }
         else if(foundOperation)
         {
            // set soap operation
            setSoapOperation(operation);
            rval = true;
         }
      }
      
      return rval;
   }
   
   /**
    * Returns true if this envelope contains a SoapOperation, false if
    * it does not.
    * 
    * @return true if this envelope contains a SoapOperation, false if
    *         it does not.
    */
   public boolean containsSoapOperation()
   {
      boolean rval = false;
      
      if(mSoapOperation != null)
      {
         rval = true;
      }
      
      return rval;
   }
   
   /**
    * Sets the SoapOperation for this envelope. Any SoapFault will be removed.
    * 
    * @param operation the SoapOperation for this envelope.
    */
   public void setSoapOperation(SoapOperation operation)
   {
      mSoapOperation = operation;
      mSoapFault = null;
      
      // clear body content from envelope
      clearBodyContents();
      
      // add body content serializer
      addBodyContentSerializer(operation);
   }
   
   /**
    * If this envelope contains a SoapOperation, then this method will return
    * it. If it does not, then this method will return null. 
    * 
    * @return the SoapOperation contained in this envelope, or null.
    */
   public SoapOperation getSoapOperation()
   {
      SoapOperation rval = null;
      
      if(containsSoapOperation())
      {
         rval = mSoapOperation;
      }
      
      return rval;      
   }
   
   /**
    * Returns true if this envelope contains a SoapFault, false if
    * it does not.
    * 
    * @return true if this envelope contains a SoapFault, false if
    *         it does not.
    */
   public boolean containsSoapFault()
   {
      boolean rval = false;
      
      if(mSoapFault != null)
      {
         rval = true;
      }
      
      return rval;
   }
   
   /**
    * Sets the SoapFault for this envelope. Any SoapOperation in this envelope
    * will be removed.
    * 
    * @param fault the SoapFault to set.
    */
   public void setSoapFault(SoapFault fault)
   {
      mSoapFault = fault;
      mSoapOperation = null;
      
      // clear body content from envelope
      clearBodyContents();
      
      // add body content serializer
      addBodyContentSerializer(fault);
   }
   
   /**
    * If this envelope contains a SoapFault, then this method will return
    * it. If it does not, then this method will return null.
    * 
    * @return the SoapFault contained in this envelope, or null.
    */
   public SoapFault getSoapFault()
   {
      SoapFault rval = null;
      
      if(containsSoapFault())
      {
         rval = mSoapFault;
      }
      
      return rval;
   }
   
   /**
    * Gets the logger for this RpcSoapEnvelope.
    * 
    * @return the logger for this RpcSoapEnvelope.
    */
   public Logger getLogger()
   {
      return LoggerManager.getLogger("dbnet");
   }   
}
<commit_msg>Removed unnecessary methods to set serializer options.<commit_after>/*
 * Copyright (c) 2006 Digital Bazaar, Inc.  All rights reserved.
 */
package com.db.net.soap;

import java.util.Iterator;

import com.db.logging.Logger;
import com.db.logging.LoggerManager;
import com.db.xml.XmlElement;

/**
 * A RpcSoapEnvelope is a SoapEnvelope that holds either a SoapOperation
 * or a SoapFault. It is specifically used to perform remote procedure calls
 * (via SoapOperations) over SOAP (Simple Object Access Protocol).
 * 
 * @author <NAME>
 */
public class RpcSoapEnvelope extends SoapEnvelope
{
   /**
    * The SoapOperation this envelope contains, if any.
    */
   protected SoapOperation mSoapOperation;
   
   /**
    * The SoapFault this envelope contains, if any.
    */
   protected SoapFault mSoapFault;
   
   /**
    * Creates a new empty RpcSoapEnvelope.
    */
   public RpcSoapEnvelope()
   {
      // no operation or fault by default
      mSoapOperation = null;
      mSoapFault = null;
   }
   
   /**
    * Returns the root tag name for this serializer.
    * 
    * @return the root tag name for this serializer.
    */
   public String getRootTag()   
   {
      // this is according to the soap envelope schema
      return "Envelope";
   }
   
   /**
    * Converts this object from an XmlElement.
    *
    * @param element the XmlElement to convert from.
    * 
    * @return true if successful, false otherwise.
    */
   public boolean convertFromXmlElement(XmlElement element)   
   {
      boolean rval = false;
      
      // clear soap operation and soap fault
      mSoapOperation = null;
      mSoapFault = null;
      
      // create a new soap operation and soap fault
      SoapOperation operation = new SoapOperation();
      SoapFault fault = new SoapFault();
      
      // convert the base class soap envelope
      if(super.convertFromXmlElement(element))
      {
         // look for a soap fault or soap operation in the body content of
         // the envelope
         boolean foundFault = false;
         boolean foundOperation = false;
         for(Iterator i = getBodyContents().iterator();
             i.hasNext() && !foundOperation && !foundFault;)
         {
            XmlElement contentElement = (XmlElement)i.next();
            
            // try to convert a fault
            if(contentElement.getRootTag().equals(fault.getRootTag()))
            {
               foundFault = fault.convertFromXmlElement(contentElement);
            }
            else
            {
               // try to convert an operation
               foundOperation = operation.convertFromXmlElement(contentElement);
            }
         }
         
         // determine if a fault or an operation was found
         if(foundFault)
         {
            // set soap fault
            setSoapFault(fault);
            rval = true;
         }
         else if(foundOperation)
         {
            // set soap operation
            setSoapOperation(operation);
            rval = true;
         }
      }
      
      return rval;
   }
   
   /**
    * Returns true if this envelope contains a SoapOperation, false if
    * it does not.
    * 
    * @return true if this envelope contains a SoapOperation, false if
    *         it does not.
    */
   public boolean containsSoapOperation()
   {
      boolean rval = false;
      
      if(mSoapOperation != null)
      {
         rval = true;
      }
      
      return rval;
   }
   
   /**
    * Sets the SoapOperation for this envelope. Any SoapFault will be removed.
    * 
    * @param operation the SoapOperation for this envelope.
    */
   public void setSoapOperation(SoapOperation operation)
   {
      mSoapOperation = operation;
      mSoapFault = null;
      
      // clear body content from envelope
      clearBodyContents();
      
      // add body content serializer
      addBodyContentSerializer(operation);
   }
   
   /**
    * If this envelope contains a SoapOperation, then this method will return
    * it. If it does not, then this method will return null. 
    * 
    * @return the SoapOperation contained in this envelope, or null.
    */
   public SoapOperation getSoapOperation()
   {
      SoapOperation rval = null;
      
      if(containsSoapOperation())
      {
         rval = mSoapOperation;
      }
      
      return rval;      
   }
   
   /**
    * Returns true if this envelope contains a SoapFault, false if
    * it does not.
    * 
    * @return true if this envelope contains a SoapFault, false if
    *         it does not.
    */
   public boolean containsSoapFault()
   {
      boolean rval = false;
      
      if(mSoapFault != null)
      {
         rval = true;
      }
      
      return rval;
   }
   
   /**
    * Sets the SoapFault for this envelope. Any SoapOperation in this envelope
    * will be removed.
    * 
    * @param fault the SoapFault to set.
    */
   public void setSoapFault(SoapFault fault)
   {
      mSoapFault = fault;
      mSoapOperation = null;
      
      // clear body content from envelope
      clearBodyContents();
      
      // add body content serializer
      addBodyContentSerializer(fault);
   }
   
   /**
    * If this envelope contains a SoapFault, then this method will return
    * it. If it does not, then this method will return null.
    * 
    * @return the SoapFault contained in this envelope, or null.
    */
   public SoapFault getSoapFault()
   {
      SoapFault rval = null;
      
      if(containsSoapFault())
      {
         rval = mSoapFault;
      }
      
      return rval;
   }
   
   /**
    * Gets the logger for this RpcSoapEnvelope.
    * 
    * @return the logger for this RpcSoapEnvelope.
    */
   public Logger getLogger()
   {
      return LoggerManager.getLogger("dbnet");
   }   
}

{'fraction_non_alphanumeric': 0.07446640316205534, 'fraction_numerical': 0.0007114624505928853, 'mean_word_length': 1.6472065285624609, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5037951', 'n_tokens_mistral': 3619, 'n_tokens_neox': 3464, 'n_words': 1086}