Package net.sf.xbus.base.core

Examples of net.sf.xbus.base.core.XException


        { // No single-value id
          if (idLoHi[0].length() == 0 || idLoHi[1].length() == 0)
          {
            // Something must be specified: single value or
            // interval.
            throw new XException(Constants.LOCATION_INTERN,
                Constants.LAYER_PROTOCOL,
                Constants.PACKAGE_PROTOCOL_RECORDS, "28");
          }
          typeIdIntervals.add(idLoHi);
        } // then (id.length()==0)
        else
        { // Single-value id found
          if (idLoHi[0].length() > 0 || idLoHi[1].length() > 0)
          {
            // Any interval specification conflicts.
            throw new XException(Constants.LOCATION_INTERN,
                Constants.LAYER_PROTOCOL,
                Constants.PACKAGE_PROTOCOL_RECORDS, "28");
          }
          typeIds.add(id);
        } // else (id.length()==0)
      } // if (recIdentMethod.equals("TypeIdentifier"))

      recordTypeNames[pos] = XDomSupport.getTrimedNodeText(recTypeDecl);
      // the record type name
      if (!XDomSupport.isValidTagName(recordTypeNames[pos]))
      {
        // It must be a legal xml tag name.
        throw new XException(Constants.LOCATION_INTERN,
            Constants.LAYER_PROTOCOL,
            Constants.PACKAGE_PROTOCOL_RECORDS, "30");
      }
      // Now look for record identification features, in particular the
      // cardinality
      // and existance indicator
      if (recOrder.equals("Ordered") || recOrder.equals("Structured"))
      { // Records are listed in the record type order or in groups.
        // The cardinality must be specified.
        String occurrences = ((Element) recTypeDecl)
            .getAttribute("Occurrences");
        if (occurrences.length() == 0)
        {
          throw new XException(Constants.LOCATION_INTERN,
              Constants.LAYER_PROTOCOL,
              Constants.PACKAGE_PROTOCOL_RECORDS, "31");
        }
        if (!CardinalityStrings.isCardinalityValid(occurrences))
        {
          throw new XException(Constants.LOCATION_INTERN,
              Constants.LAYER_PROTOCOL,
              Constants.PACKAGE_PROTOCOL_RECORDS, "32");
        }

        // The first record in a record group must have cardinality 1.
        if (recOrder.equals("Structured") && pos == 0)
        {
          try
          {
            int occurrNum = Integer.parseInt(occurrences);
            if (occurrNum != 1)
            {
              throw new XException(Constants.LOCATION_INTERN,
                  Constants.LAYER_PROTOCOL,
                  Constants.PACKAGE_PROTOCOL_RECORDS, "33");
            }
          } // try
          catch (NumberFormatException e)
          {
            throw new XException(Constants.LOCATION_INTERN,
                Constants.LAYER_PROTOCOL,
                Constants.PACKAGE_PROTOCOL_RECORDS, "33");
          } // catch
        } // if (recOrder.equals("Structured") && pos==0)

        // If the record type is not given by an id but the cardinality
        // is specified as an
        // interval and there are also other record types, there must be
        // an existance indicator
        // refering the preceding record.
        if (recordTypesCount > 1
            && !recIdentMethod.equals("TypeIdentifier")
            && CardinalityStrings.isCardinalityInterval(
                occurrences, true))
        {
          String existIndField = ((Element) recTypeDecl)
              .getAttribute("ExistIndicatorField");
          // Indicator field specified by name
          if (existIndField.length() == 0)
          {
            throw new XException(Constants.LOCATION_INTERN,
                Constants.LAYER_PROTOCOL,
                Constants.PACKAGE_PROTOCOL_RECORDS, "35");
          }
          String existIndValue = ((Element) recTypeDecl)
              .getAttribute("ExistIndicatorValue");
          if (existIndValue.length() == 0)
          {
            throw new XException(Constants.LOCATION_INTERN,
                Constants.LAYER_PROTOCOL,
                Constants.PACKAGE_PROTOCOL_RECORDS, "36");
          }
          precedingIndicator = new String[2];
          precedingIndicator[0] = existIndField;
          precedingIndicator[1] = existIndValue;
          // If the record type may occurr more than once, it may be
          // its
          // predecessor itself.
          if (CardinalityStrings
              .getCardinalityHigh(occurrences, true) > 1)
          {
            existanceIndicators[pos] = new TreeMap();
            existanceIndicators[pos].put(precedingIndicator[0],
                precedingIndicator[1]);
          } // if (getCardinalityHigh(occurrences,true)>1)
        } // if (!recIdentMethod.equals("TypeIdentifier") &&
        // isCardinalityInterval(occurrences,true))
      } // if (recOrder.equals("Ordered") ||
      // recOrder.equals("Structured"))
    } // try
    catch (ClassCastException e)
    {
      throw new XException(Constants.LOCATION_INTERN,
          Constants.LAYER_PROTOCOL,
          Constants.PACKAGE_PROTOCOL_RECORDS, "0", e);
    } // catch
    return precedingIndicator;
    // Group starting record type found?
View Full Code Here


    if (srcFile.exists())
    {
      // 1.check if resolution = error
      if (mConfiguration.getResolution().equals(Constants.WRITE_ERROR))
      {
        throw new XException(Constants.LOCATION_EXTERN,
            Constants.LAYER_TECHNICAL,
            Constants.PACKAGE_TECHNICAL_FILE, "29");
      }

      // 2. check if it is one file
      if (!srcFile.isFile())
      {
        List params = new Vector();
        params.add(mConfiguration.getFileNames());
        throw new XException(Constants.LOCATION_EXTERN,
            Constants.LAYER_TECHNICAL,
            Constants.PACKAGE_TECHNICAL_FILE, "30", params);
      }

      // 3. check write permissions
      if (!srcFile.canWrite())
      {
        List params = new Vector();
        params.add(fileName);
        throw new XException(Constants.LOCATION_EXTERN,
            Constants.LAYER_TECHNICAL,
            Constants.PACKAGE_TECHNICAL_FILE, "31", params);
      }
    }
  }
View Full Code Here

        else
        // Extension if no prior DTD validating
        {
          List params = new Vector();
          params.add(fieldSpec.getNodeName());
          throw new XException(Constants.LOCATION_INTERN,
              Constants.LAYER_PROTOCOL,
              Constants.PACKAGE_PROTOCOL_RECORDS, "38", params);
        }
      } // for (int i=0; i<fieldSpecs.getLength(); i++)
    } // try
    catch (ClassCastException e)
    {
      throw new XException(Constants.LOCATION_INTERN,
          Constants.LAYER_PROTOCOL,
          Constants.PACKAGE_PROTOCOL_RECORDS, "0", e);
    } // catch
  } // checkFieldsAndGroupRefs(Node parent, Node groupsSpec, TreeMap
View Full Code Here

    }
    catch (Exception e)
    {
      List params = new Vector(1);
      params.add(cmdarray[0]);
      throw new XException(Constants.LOCATION_INTERN,
          Constants.LAYER_TECHNICAL,
          Constants.PACKAGE_TECHNICAL_MISC, "6", e, params);
    }

    // Input piped to the called process
    List internalCommands = getProcessInputs();
    if (internalCommands != null && internalCommands.size() > 0)
    {
      BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
          mProcess.getOutputStream()));
      try
      {
        for (int i = 0; i < internalCommands.size(); i++)
        {
          writer.write((String) internalCommands.get(i));
          writer.newLine();
        }
        writer.flush();
      }
      catch (IOException e)
      {
        List params = new Vector(1);
        params.add(cmdarray[0]);
        throw new XException(Constants.LOCATION_INTERN,
            Constants.LAYER_TECHNICAL,
            Constants.PACKAGE_TECHNICAL_MISC, "7", e, params);
      }
      finally
      {
        try
        {
          writer.close();
        }
        catch (IOException e)
        {
          // do nothing
        }
      }
    }

    InputStreamReader reader = new InputStreamReader(mProcess
        .getInputStream());
    int character = 0;
    byte[] ba = new byte[1];
    String oneChar = null;
    StringBuffer buffer = new StringBuffer();

    try
    {
      while ((character = reader.read()) >= 0)
      {
        ba[0] = new Integer(character).byteValue();
        oneChar = new String(ba);
        buffer.append(oneChar);
        System.out.print(oneChar);
      }
    }
    catch (IOException e)
    {
      List params = new Vector(1);
      params.add(cmdarray[0]);
      throw new XException(Constants.LOCATION_INTERN,
          Constants.LAYER_TECHNICAL,
          Constants.PACKAGE_TECHNICAL_MISC, "7", e, params);
    }
    finally
    {
      try
      {
        reader.close();
      }
      catch (IOException e)
      {
        // do nothing
      }
    }

    try
    {
      mProcess.waitFor();
    }
    catch (InterruptedException e)
    {
      List params = new Vector(1);
      params.add(cmdarray[0]);
      throw new XException(Constants.LOCATION_INTERN,
          Constants.LAYER_TECHNICAL,
          Constants.PACKAGE_TECHNICAL_MISC, "7", e, params);
    }

    return buffer.toString();
View Full Code Here

      String groupName = groupRef.getAttribute("Name");

      // Extension if no prior DTD validating
      if (groupName.length() == 0)
      {
        throw new XException(Constants.LOCATION_INTERN,
            Constants.LAYER_PROTOCOL,
            Constants.PACKAGE_PROTOCOL_RECORDS, "40");
      }
      // Search for the group specification.
      if (groupsSpec == null)
      {
        throw new XException(Constants.LOCATION_INTERN,
            Constants.LAYER_PROTOCOL,
            Constants.PACKAGE_PROTOCOL_RECORDS, "41");
      }
      List groups = XDomSupport.getChildNodesByAttrValue(groupsSpec,
          "Name", groupName, "GroupSpec");
      if (groups == null || groups.size() == 0)
      {
        throw new XException(Constants.LOCATION_INTERN,
            Constants.LAYER_PROTOCOL,
            Constants.PACKAGE_PROTOCOL_RECORDS, "42");
      }
      if (groups.size() > 1)
      {
        throw new XException(Constants.LOCATION_INTERN,
            Constants.LAYER_PROTOCOL,
            Constants.PACKAGE_PROTOCOL_RECORDS, "43");
      }
      // Group specification found

      // some existance indicators to search for
      if (existanceIndicators != null)
      {
        NodeList fields = ((Node) groups.get(0)).getChildNodes();
        for (int i = 0; i < fields.getLength(); i++)
        {
          String name = ((Element) fields.item(i))
              .getAttribute("Name");
          String value = (String) existanceIndicators.get(name);
          if (value != null)
          {
            if (value.equals("Found"))
            {
              // Will always occurr if a record type contains more
              // than one instance of
              // a group. Thus, existance indicators in group
              // should not occurr.
              throw new XException(Constants.LOCATION_INTERN,
                  Constants.LAYER_PROTOCOL,
                  Constants.PACKAGE_PROTOCOL_RECORDS, "44");
            }
            int length = Integer
                .parseInt(((Element) fields.item(i))
                    .getAttribute("Length"));
            if (value.length() != length)
            {
              throw new XException(Constants.LOCATION_INTERN,
                  Constants.LAYER_PROTOCOL,
                  Constants.PACKAGE_PROTOCOL_RECORDS, "45");
            }
            // Mark as found.
            existanceIndicators.put(name, "Found");
          } // if (value!=null)
        } // for (int i=0; i<fields.getLength(); i++)
      } // if (existanceIndicators!=null)
    } // try
    catch (ClassCastException e)
    {
      throw new XException(Constants.LOCATION_INTERN,
          Constants.LAYER_PROTOCOL,
          Constants.PACKAGE_PROTOCOL_RECORDS, "0", e);
    }
    catch (NumberFormatException e)
    {
      throw new XException(Constants.LOCATION_INTERN,
          Constants.LAYER_PROTOCOL,
          Constants.PACKAGE_PROTOCOL_RECORDS, "0", e);
    }
  } // checkGroupReference(Element groupRef, Node groupsSpec, TreeMap
View Full Code Here

      if (!validated)
      { // Extension if no prior DTD validating
        if (name.length() == 0)
        {
          throw new XException(Constants.LOCATION_INTERN,
              Constants.LAYER_PROTOCOL,
              Constants.PACKAGE_PROTOCOL_RECORDS, "48");
        }
        if (length.length() == 0)
        {
          throw new XException(Constants.LOCATION_INTERN,
              Constants.LAYER_PROTOCOL,
              Constants.PACKAGE_PROTOCOL_RECORDS, "49");
        }
        if (format.length() == 0)
        {
          throw new XException(Constants.LOCATION_INTERN,
              Constants.LAYER_PROTOCOL,
              Constants.PACKAGE_PROTOCOL_RECORDS, "50");
        }
      } // if (!validated)

      // For dates further format infoamtion is mandatory.
      if (format.equals("date")
          && fieldSpec.getAttribute("DateFormat").length() == 0)
      {
        throw new XException(Constants.LOCATION_INTERN,
            Constants.LAYER_PROTOCOL,
            Constants.PACKAGE_PROTOCOL_RECORDS, "51");
      }

      // The length must be an strictly positive integer
      int lengthNum = Integer.parseInt(length);
      if (lengthNum < 1)
      {
        throw new XException(Constants.LOCATION_INTERN,
            Constants.LAYER_PROTOCOL,
            Constants.PACKAGE_PROTOCOL_RECORDS, "52");
      }
      // Constant values must be bound to a value.
      if (format.equals("const"))
      {
        String value = fieldSpec.getAttribute("Value");
        if (value.length() == 0)
        {
          throw new XException(Constants.LOCATION_INTERN,
              Constants.LAYER_PROTOCOL,
              Constants.PACKAGE_PROTOCOL_RECORDS, "53");
        }
        else if (value.length() != lengthNum)
        {
          throw new XException(Constants.LOCATION_INTERN,
              Constants.LAYER_PROTOCOL,
              Constants.PACKAGE_PROTOCOL_RECORDS, "54");
        }
      } // if (fieldSpec.getAttribute("Format").equals("const"))

      // some existance indicators to search for
      if (existanceIndicators != null)
      {
        String value = (String) existanceIndicators.get(name);
        if (value != null)
        { // existance indicator defined for this field
          if (value.equals("Found"))
          {
            // Already found for other field
            throw new XException(Constants.LOCATION_INTERN,
                Constants.LAYER_PROTOCOL,
                Constants.PACKAGE_PROTOCOL_RECORDS, "44");
          }
          if (value.length() != lengthNum)
          {
            throw new XException(Constants.LOCATION_INTERN,
                Constants.LAYER_PROTOCOL,
                Constants.PACKAGE_PROTOCOL_RECORDS, "45");
          }
          // Mark as found.
          existanceIndicators.put(name, "Found");
        } // if (value!=null)
      } // if (existanceIndicators!=null)
    } // try
    catch (NumberFormatException e)
    {
      throw new XException(Constants.LOCATION_INTERN,
          Constants.LAYER_PROTOCOL,
          Constants.PACKAGE_PROTOCOL_RECORDS, "0", e);
    } // catch
    catch (ClassCastException e)
    {
      throw new XException(Constants.LOCATION_INTERN,
          Constants.LAYER_PROTOCOL,
          Constants.PACKAGE_PROTOCOL_RECORDS, "0", e);
    } // catch
  } // checkFieldSpecification(Element fieldSpec, TreeMap
View Full Code Here

   */
  public void checkGroupSpecification(Element groupSpec) throws XException
  {
    if (groupSpec.getAttribute("Name").length() == 0)
    {
      throw new XException(Constants.LOCATION_INTERN,
          Constants.LAYER_PROTOCOL,
          Constants.PACKAGE_PROTOCOL_RECORDS, "59");
    }
    try
    // for casting to XException
    {
      NodeList fieldSpecs = groupSpec.getChildNodes();
      // fields in the group
      for (int i = 0; i < fieldSpecs.getLength(); i++)
      { // Loop over all group fields
        if (!((Element) fieldSpecs.item(i)).getNodeName().equals(
            "Field"))
        {
          throw new XException(Constants.LOCATION_INTERN,
              Constants.LAYER_PROTOCOL,
              Constants.PACKAGE_PROTOCOL_RECORDS, "60");
        }
      } // for (int i=0; i<fieldSpecs.getLength(); i++)
    } // try
    catch (ClassCastException e)
    {
      throw new XException(Constants.LOCATION_INTERN,
          Constants.LAYER_PROTOCOL,
          Constants.PACKAGE_PROTOCOL_RECORDS, "0", e);
    } // catch
  } // checkGroupSpecification(Node groupSpec)
View Full Code Here

          fieldLengthSum += computeGroupLength(fieldSpec, groupsSpec);
      } // for (int i=0; i<fieldSpecs.getLength(); i++)
    }
    catch (NumberFormatException e)
    {
      throw new XException(Constants.LOCATION_INTERN,
          Constants.LAYER_PROTOCOL,
          Constants.PACKAGE_PROTOCOL_RECORDS, "0", e);
    }
    return fieldLengthSum;
  } // computeRecordLength(Element spec)
View Full Code Here

        if (fieldSpec.getNodeName().equals("Field"))
          groupLengthSum += Integer.parseInt(fieldSpec
              .getAttribute("Length"));
        else
        {
          throw new XException(Constants.LOCATION_INTERN,
              Constants.LAYER_PROTOCOL,
              Constants.PACKAGE_PROTOCOL_RECORDS, "63");
        }
      } // for (int i=0; i<fieldSpecs.getLength(); i++)
    } // try
    catch (NumberFormatException e)
    {
      throw new XException(Constants.LOCATION_INTERN,
          Constants.LAYER_PROTOCOL,
          Constants.PACKAGE_PROTOCOL_RECORDS, "0", e);
    } // catch
    return groupLengthSum;
  } // computeGroupLength(Element groupRef, Node groupsSpec)
View Full Code Here

    {
      List groups = XDomSupport.getChildNodesByAttrValue(groupsSpec,
          "Name", groupName, "GroupSpec");
      if (groups.size() != 1)
      {
        throw new XException(Constants.LOCATION_INTERN,
            Constants.LAYER_PROTOCOL,
            Constants.PACKAGE_PROTOCOL_RECORDS, "65");
      }
      result = (Node) groups.get(0);
    } // try
    catch (ClassCastException e)
    {
      throw new XException(Constants.LOCATION_INTERN,
          Constants.LAYER_PROTOCOL,
          Constants.PACKAGE_PROTOCOL_RECORDS, "0", e);
    } // catch
    return result;
  } // getGroupSpec(String groupName, Node groupsSpec)
View Full Code Here

TOP

Related Classes of net.sf.xbus.base.core.XException

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.