Пример #1
0
 /**
  * This util method is used to retrieve the string tokens resides in a particular udt parameter.
  *
  * @param param Name of the parameter
  * @return
  */
 public static Queue<String> getTokens(String param) {
   boolean isString = false;
   Queue<String> tokens = new LinkedBlockingQueue<String>();
   char[] chars = param.toCharArray();
   StringBuilder columnName = new StringBuilder();
   for (int i = 0; i < chars.length; i++) {
     Character c = chars[i];
     if (!".".equals(c.toString()) && !"[".equals(c.toString()) && !"]".equals(c.toString())) {
       isString = true;
       columnName.append(c.toString());
       if (i == chars.length - 1) {
         tokens.add(columnName.toString());
       }
     } else {
       if (isString) {
         tokens.add(columnName.toString());
         columnName = new StringBuilder();
         isString = false;
       }
       tokens.add(c.toString());
     }
   }
   return tokens;
 }
Пример #2
0
 /**
  * This method is used to embed syntaxes associated with UDT attribute notations to a queue of
  * string tokens extracted from a UDT parameter.
  *
  * @param tokens Queue of string tokens
  * @param syntaxQueue Syntax embedded tokens
  * @param isIndex Flag to determine whether a particular string token is an inidex or a column
  *     name
  */
 public static void getSyntaxEmbeddedQueue(
     Queue<String> tokens, Queue<String> syntaxQueue, boolean isIndex) {
   if (!tokens.isEmpty()) {
     if ("[".equals(tokens.peek())) {
       isIndex = true;
       tokens.poll();
       syntaxQueue.add("INEDX_START");
       syntaxQueue.add(tokens.poll());
     } else if ("]".equals(tokens.peek())) {
       isIndex = false;
       tokens.poll();
       syntaxQueue.add("INDEX_END");
     } else if (".".equals(tokens.peek())) {
       tokens.poll();
       syntaxQueue.add("DOT");
       syntaxQueue.add("COLUMN");
       syntaxQueue.add(tokens.poll());
     } else {
       if (isIndex) {
         syntaxQueue.add("INDEX");
         syntaxQueue.add(tokens.poll());
       } else {
         syntaxQueue.add("COLUMN");
         syntaxQueue.add(tokens.poll());
       }
     }
     getSyntaxEmbeddedQueue(tokens, syntaxQueue, isIndex);
   }
 }