Package com.bansheeproject.exceptions

Examples of com.bansheeproject.exceptions.InvalidQueryException


 
  private void validateString (String queryString) {
   
    //Check if the query string is empty
    if (queryString == null || queryString.trim().equals("")) {
      throw new InvalidQueryException("Query string must not be empty");
    }
   
    //Check if the query string is not composed only by the node delimiter
    if (queryString.charAt(0) == NODE_DELIMITER && queryString.substring(1).trim().equals("") ) {
      throw new InvalidQueryException("Query string must be composed by one or more nodes.");
    }
   
   
    //Disables queries beginning with a node delimiter
    if (queryString.charAt(0) == NODE_DELIMITER) {
      queryString = queryString.substring(1);
    }
   
    String[] pieces = breakQueryString(queryString);
   
   
   
    for (String piece : pieces) {
     
      //Checks if it contains an illegal syntax for declaring elements
      if ((piece.contains(String.valueOf(OPEN_NAMESPACE_CHARACTER)) && !piece.contains(String.valueOf(CLOSE_NAMESPACE_CHARACTER))) ||
          piece.contains(String.valueOf(CLOSE_NAMESPACE_CHARACTER)) && !piece.contains(String.valueOf(OPEN_NAMESPACE_CHARACTER))){
        throw new InvalidQueryException("Namespace declaration in piece " + piece + " is illegal.");
      }
     
     
      if (piece.contains(String.valueOf(OPEN_NAMESPACE_CHARACTER))) {
        String namespace = getQueryNamespace(piece);
View Full Code Here


    piece = piece.trim();
   
    //Elements or namespaces must not start by anything but a letter
    if (piece.length() > 1) {
      if (! Character.isLetter(piece.charAt(0)) && !ALLOWED_CHARACTERS_NAMESPACE.contains(String.valueOf(piece.charAt(0)))) {
        throw new InvalidQueryException("Namespace declaration " + piece + " is illegal. It must start with a letter.");
      }
    }
   
    //Elements or namespaces must not contain anything but letters and numbers
    for (int i = 1; i < piece.length(); i++) {
      if (!Character.isLetter(piece.charAt(i)) && !Character.isDigit(piece.charAt(i)) && !ALLOWED_CHARACTERS_NAMESPACE.contains(String.valueOf(piece.charAt(i)))) {
        throw new InvalidQueryException("Namespace declaration " + piece + " is illegal, as it contains the character " + piece.charAt(i));
      }
    }
  }
View Full Code Here

   
    //Elements or namespaces must not start by anything but a letter
    if (piece.length() > 1) {
      if (! Character.isLetter(piece.charAt(0)) &&
          (!(piece.charAt(0) == ATTRIBUTE_INDEX) )) {
        throw new InvalidQueryException("Local part declaration " + piece + " is illegal. It must start with a letter.");
      }
    }
   
    //Elements or namespaces must not contain anything but letters and numbers
    for (int i = 1; i < piece.length(); i++) {
      if (!Character.isLetter(piece.charAt(i)) && !Character.isDigit(piece.charAt(i)) && !ALLOWED_CHARACTERS_LOCAL.contains(String.valueOf(piece.charAt(i)))) {
        throw new InvalidQueryException("Local part declaration " + piece + " is illegal, as it contains the character " + piece.charAt(i));
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.bansheeproject.exceptions.InvalidQueryException

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.