Examples of PAViolation


Examples of com.uic.ase.proj.xbn.array.primitive.PAViolation

    <P><B>Be careful when calling this function directly.</B>  You can call this function manually, but if the [thing being wrapped to look like an array] is not valid, you will get unpredictable results when using this class or its functions.  Moral:  Don't call this function unless you know what you're doing.</P>

    <P>Equal to <CODE><A HREF="~JD~setPAViolation(pav)~EJD~">setPAViolation</A>(new <A HREF="~JD~pav#pav()~EJD~">PAViolation</A>())</CODE></P>
   **/
  protected final void declareNoViolation()  {
    setPAViolation(new PAViolation());
  }
View Full Code Here

Examples of com.uic.ase.proj.xbn.array.primitive.PAViolation

      boolean bAXIfBad = (s_callingClsFnc != null  ||  s_varName != null);
    //To make the below code a bit more consice...END

    if(!bNullOk)  {
      if(isNull())  {
        setPAViolation(new PAViolation(PAViolation.getType_NULL()));
        if(bAXIfBad)  {
          throwAXIllegal(s_callingClsFnc, s_varName, "isNull() equals true.");
        }
        return false;
      }

    }  else if(isNull())  {
      //A null array cannot be analyzed further.
      declareNoViolation();
      return true;
    }
    //The array is not null.

    if(!rclArray.isValid(getLength()))  {
      setPAViolation(new PAViolation(PAViolation.getType_LENGTH()));
      if(bAXIfBad)  {
        throwAXIllegal(s_callingClsFnc, s_varName, "the number of elements in the array (" + getLength() + ") is illegal according to getPARChar().getArrayRCL().isValid().");
      }
      return false;

    else if(getLength() < 1)  {
      //The array is zero elements in length, and this is okay.
      //An empty array can, but does not need to be analyzed further.
      declareNoViolation();
      return true;
    }
    //The string array has at least one element.

    for(int i = 0; i < getLength(); i++)  {
      if(getPARChar().hasIllegalChars())  {
        //At least one char is considered illegal.
        if(getPARChar().isIllegal(getChar(i)))  {
          setPAViolation(new PAViolation(PAViolation.getType_LMNT_ILLEGAL(), i));
          if(bAXIfBad)  {
            throwAXIllegal(s_callingClsFnc, s_varName, "Element " + i + " ('" + getChar(i) + "') is illegal.  getPARChar().isIllegal('" + getChar(i) + "') equals true.");
          }
          return false;
        }
      }
      //Element i is not equal to any of the illegal characters, or there
      //are no illegal chars.

      //Compare this element with every element after this one (i + 1)
      for(int j = (i + 1); j < getLength(); j++)  {
        if(!bDupsOk)  {
          //Duplicates are not good.
          if(getChar(i) == getChar(j))  {
            setPAViolation(new PAViolation(PAViolation.getType_LMNT_DUPLICATE(), i, j));
            if(bAXIfBad)  {
              throwAXIllegal(s_callingClsFnc, s_varName, "elements " + i + " and " + j + " are equal ('" + getChar(i) + "').");
            }
            return false;
          }
        }  //ELSE:  It is okay for elements to equal one
           //       another.

        //It is not possible for a character to contain
        //another (given that if two characters are "equal"
        //they are not considered "contained").

        if(getPARChar().getPAROrderDir().isOrdered())  {
          //Ordering is required.

          boolean bOrderDirAD = getPARChar().getPAROrderDir().getDirectionAscDesc();
          if(bOrderDirAD)  {
            //Order direction is ascending
            if(getChar(i) > getChar(j))  {
              setPAViolation(new PAViolation(PAViolation.getType_LMNT_OOORDER(), i, j));
              if(bAXIfBad)  {
                throwAXIllegal(s_callingClsFnc, s_varName, "element " + i + "  ('" + getChar(i) + "') is greater than " + j + " ('" + getChar(j) + "').");
              }
              return false;
            }
            //i is less than j.  GOOD.
            continue;

          }
          //Order direction is descending

          if(getChar(i) < getChar(j))  {
            setPAViolation(new PAViolation(PAViolation.getType_LMNT_OOORDER(), i, j));
            if(bAXIfBad)  {
              throwAXIllegal(s_callingClsFnc, s_varName, "element " + i + "  ('" + getChar(i) + "') is less than " + j + " ('" + getChar(j) + "').");
            }
            return false;
          }
View Full Code Here

Examples of com.uic.ase.proj.xbn.array.primitive.PAViolation

      boolean bAXIfBad = (s_callingClsFnc != null  ||  s_varName != null);
    //To make the below code a bit more consice...END

    if(!bNullOk)  {
      if(isNull())  {
        setPAViolation(new PAViolation(PAViolation.getType_NULL()));
        if(bAXIfBad)  {
          throwAXIllegal(s_callingClsFnc, s_varName, "isNull() equals true.");
        }
        return false;
      }


    }  else if(isNull())  {

      //A null array cannot be analyzed further.
      declareNoViolation();
      return true;
    }
    //The array is not null.


    if(!rclArray.isValid(getLength()))  {
      setPAViolation(new PAViolation(PAViolation.getType_LENGTH()));
      if(bAXIfBad)  {
        throwAXIllegal(s_callingClsFnc, s_varName, "the number of elements in the array (" + getLength() + ") is illegal according to getPARString().getPARDupNullLen().getRCLength().isValid().");
      }

      return false;

    else if(getLength() < 1)  {

      //The array is zero elements in length, and this is okay.
      //An empty array can, but does not need to be analyzed further.
      declareNoViolation();
      return true;
    }
    //The string array has at least one element.

    final String sLMNT = "element ";
    final String sPRN_QT = " ('";

    for(int i = 0; i < getLength(); i++)  {

      if(!bNullLmntOk  &&  getString(i) == null)  {
        //A null element is bad.

        setPAViolation(new PAViolation(PAViolation.getType_SLMNT_NULL(), i));
        if(bAXIfBad)  {
          throwAXIllegal(s_callingClsFnc, s_varName, sLMNT + i + " is null.");
        }

        return false;
      }
      //If the element is null, this is okee dokee.


      if(getString(i) != null  &&  !rclLmnt.isValid(getString(i).length()))  {
        setPAViolation(new PAViolation(PAViolation.getType_SLMNT_LENGTH(), i));;
        if(bAXIfBad)  {
          throwAXIllegal(s_callingClsFnc, s_varName, "the length of element " + i + sPRN_QT + getString(i) + "', length " + getString(i).length() + ") is illegal according to getPARString().getPARSElement().getRCLength().isValid().");
        }

        return false;
      }
      //Element i is either null-and-this-is-okay, or
      //non-null-and-its-length-is-valid


      if(getPARString().getPARSElement().hasIllegalStrings()  &&
          getPARString().getPARSElement().isIllegal(getString(i)))  {

        setPAViolation(new PAViolation(PAViolation.getType_LMNT_ILLEGAL(), i));
        if(bAXIfBad)  {
          throwAXIllegal(s_callingClsFnc, s_varName, sLMNT + i + " is an illegal string.  getPARString().getPARSElement().isIllegal('" + getString(i) + "') equals true.");
        }

        return false;
      }

      //Compare this element with every element after this one (i + 1)
      for(int j = (i + 1); j < getLength(); j++)  {

        if(!bDupsOk)  {
          //Duplicates are not good.

          if((getString(i) == null  &&  getString(j) == null||
              (getString(i) != null  &&  getString(j) != null  &&  getString(i).equals(getString(j))))  {
            setPAViolation(new PAViolation(PAViolation.getType_LMNT_DUPLICATE(), i, j));
            if(bAXIfBad)  {
              throwAXIllegal(s_callingClsFnc, s_varName, "elements " + i + " and " + j + " are equal:  '" + getString(i) + "'.");
            }
            return false;
          }

        }  //ELSE:  It is okay for elements to equal one
           //       another.

        if(!bContainmentOk)  {
          //It is not okay for one element to be contained
          //in another.  "Contained in" does not mean "equal to".

          if(getString(i) != null  &&  getString(j) != null  &&
              !getString(i).equals(getString(j)))  {
            //i and j are non-null, and unique.  These two
            //strings can be analyzed to see if they are
            //contained in one another.

            if(!bOrderedContainment  ||
                (bOrderedContainment  &&  bContainOrderAscDesc))  {
              //ASC:  Low idxs can exist in high idxs, but not vice versa.
              //DESC:  High idxs can contain low idxs, but not vice versa.
              if(getString(i).indexOf(getString(j)) != -1)  {
                setPAViolation(new PAViolation(PAViolation.getType_SLMNT_CONTAINED(), i, j, getString(i).indexOf(getString(j))));
                if(bAXIfBad)  {
                  throwAXIllegal(s_callingClsFnc, s_varName, sLMNT + i + sPRN_QT + getString(i) + "') contains (but is not equal to) element " + j + sPRN_QT + getString(j) + "') at array index " + getPAViolation().getContainedAtIdx() + ".");
                }
                return false;
              }
            }

            if(!bOrderedContainment  ||
                (bOrderedContainment  &&  !bContainOrderAscDesc))  {
              //DESC:  High idxs can exist in low idxs, but not vice versa.
              //DESC:  Low idxs can contain high idxs, but not vice versa.
              if(getString(j).indexOf(getString(i)) != -1)  {
                setPAViolation(new PAViolation(PAViolation.getType_SLMNT_CONTAINED(), j, i, getString(j).indexOf(getString(i))));
                if(bAXIfBad)  {
                  throwAXIllegal(s_callingClsFnc, s_varName, sLMNT + i + sPRN_QT + getString(i) + "') is contained by (but is not equal to) element " + j + sPRN_QT + getString(j) + "') at array index " + getPAViolation().getContainedAtIdx() + ".");
                }
                return false;
              }
            }
          }  //ELSE:  i and/or j is null, or both are non-
            //       null and equal to each other.  Null
            //       strings cannot be contained in any
            //       other.

        //ELSE:  It is okay for elements to contain (not
          //       equal) one another.


        if(getPARString().getPAROrderDir().isOrdered())  {

          //Ordering is required.

          if(getPARString().getPAROrderDir().getDirectionAscDesc())  {
            //Order direction is ascending

            if(getString(i).compareTo(getString(j)) > 0)  {
              setPAViolation(new PAViolation(PAViolation.getType_LMNT_OOORDER(), i, j));
              if(bAXIfBad)  {
                throwAXIllegal(s_callingClsFnc, s_varName, "elements " + i + " and " + j + " are both non-null, but " + i + " is greater than " + j + sPRN_QT + getString(i) + "'.compareTo('" + getString(j) + "') equals " + getString(i).compareTo(getString(j)) + ").");
              }
              return false;
            }
            //i is less than j.  GOOD.

            continue;

          }
          //Order direction is descending

          if(getString(i).compareTo(getString(j)) < 0)  {
            setPAViolation(new PAViolation(PAViolation.getType_LMNT_OOORDER(), i, j));
            if(bAXIfBad)  {
              throwAXIllegal(s_callingClsFnc, s_varName, "elements " + i + " and " + j + " are both non-null, but " + i + " is less than " + j + sPRN_QT + getString(i) + "'.compareTo('" + getString(j) + "') equals " + getString(i).compareTo(getString(j)) + ").");
            }
            return false;
          }
View Full Code Here

Examples of com.uic.ase.proj.xbn.array.primitive.PAViolation

      boolean bAXIfBad = (s_callingClsFnc != null  ||  s_varName != null);
    //To make the below code a bit more consice...END

    if(!bNullOk)  {
      if(isNull())  {
        setPAViolation(new PAViolation(PAViolation.getType_NULL()));
        if(bAXIfBad)  {
          throwAXIllegal(s_callingClsFnc, s_varName, "isNull() equals true.");
        }
        return false;
      }

    }  else if(isNull())  {
      //A null array cannot be analyzed further.
      declareNoViolation();
      return true;
    }
    //The array is not null.

    if(!rclArray.isValid(getLength()))  {
      setPAViolation(new PAViolation(PAViolation.getType_LENGTH()));
      if(bAXIfBad)  {
        throwAXIllegal(s_callingClsFnc, s_varName, "the number of elements in the array (" + getLength() + ") is illegal according to getPARInt().getArrayRCL().isValid().");
      }
      return false;

    else if(getLength() < 1)  {
      //The array is zero elements in length, and this is okay.
      //An empty array can, but does not need to be analyzed further.
      declareNoViolation();
      return true;
    }
    //The string array has at least one element.

    final String sLMNT = "element ";

    for(int i = 0; i < getLength(); i++)  {
      if(!rcLmnt.isValid(getInt(i)))  {
        setPAViolation(new PAViolation(PAViolation.getType_ILMNT_OOBOUNDS(), i));
        if(bAXIfBad)  {
          throwAXIllegal(s_callingClsFnc, s_varName, sLMNT + i + " ('" + getInt(i) + "') is illegal according to getPARInt().getRCLength().isValid().");
        }
        return false;
      }
      //Element i is valid according to the range.

      if(getPARInt().getPARIElement().hasIllegalInts())  {
        //There is at least one int considered illegal

        if(getPARInt().getPARIElement().isIllegal(getInt(i)))  {
          setPAViolation(new PAViolation(PAViolation.getType_LMNT_ILLEGAL(), i));
          if(bAXIfBad)  {
            throwAXIllegal(s_callingClsFnc, s_varName, sLMNT + i + " (" + getInt(i) + ") is illegal.  getPARInt().getPARIElement().isIllegal(" + getInt(i) + ") equals true.");
          }
          return false;
        }
      }
      //Element i is not equal to any of the illegal characters, or there
      //are no illegal chars.

      //Compare this element with every element after this one (i + 1)
      for(int j = (i + 1); j < getLength(); j++)  {
        if(!bDupsOk)  {
          //Duplicates are not good.
          if(getInt(i) == getInt(j))  {
            setPAViolation(new PAViolation(PAViolation.getType_LMNT_DUPLICATE(), i, j));
            if(bAXIfBad)  {
              throwAXIllegal(s_callingClsFnc, s_varName, "elements " + i + " and " + j + " are equal ('" + getInt(i) + "').");
            }
          return false;
          }
        }  //ELSE:  It is okay for elements to equal one
           //       another.

        //I don't care if ints are contained in one another.
        //If you want to test for this, then use a
        //PrimitiveArrayString (like PASInt).

        if(bOrdered)  {
          //Ordering is required.

          if(getPARInt().getPAROrderDir().getDirectionAscDesc())  {
            //Order direction is ascending
            if(getInt(i) > getInt(j))  {
              setPAViolation(new PAViolation(PAViolation.getType_LMNT_OOORDER(), i, j));
              if(bAXIfBad)  {
                throwAXIllegal(s_callingClsFnc, s_varName, sLMNT + i + "  (" + getInt(i) + ") is greater than " + j + " (" + getInt(j) + ").");
              }
              return false;
            }
            //i is less than j.  GOOD.
            continue;

          }
          //Order direction is descending

          if(getInt(i) < getInt(j))  {
            setPAViolation(new PAViolation(PAViolation.getType_LMNT_OOORDER(), i, j));
            if(bAXIfBad)  {
              throwAXIllegal(s_callingClsFnc, s_varName, sLMNT + i + "  (" + getInt(i) + ") is less than " + j + " (" + getInt(j) + ").");
            }
            return false;
          }
View Full Code Here
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.