コード例 #1
0
 /**
  * Flush and invoke appropriate optype
  *
  * @param optype the optype
  * @param index the index
  * @param type the type
  * @param id the id
  * @throws IOException
  */
 public void flush(String optype, String index, String type, String id) throws IOException {
   if (!map.isEmpty()) {
     build(map);
     if (listener != null) {
       if ("create".equals(optype)) {
         listener.create(index, type, id, version, builder);
       } else if ("index".equals(optype)) {
         listener.index(index, type, id, version, builder);
       } else if ("delete".equals(optype)) {
         listener.delete(index, type, id);
       }
     }
     if (index != null) {
       digest.update(index.getBytes("UTF-8"));
     }
     if (type != null) {
       digest.update(type.getBytes("UTF-8"));
     }
     if (id != null) {
       digest.update(id.getBytes("UTF-8"));
     }
     builder.close();
     builder = jsonBuilder();
     map = new HashMap();
   }
 }
コード例 #2
0
ファイル: Rule.java プロジェクト: damc-dev/byteman
  private Rule(RuleScript ruleScript, ClassLoader loader, HelperManager helperManager)
      throws ParseException, TypeException, CompileException {
    ParseNode ruleTree;

    this.ruleScript = ruleScript;
    this.helperClass = null;
    this.loader = loader;

    typeGroup = new TypeGroup(loader);
    bindings = new Bindings();
    checked = false;
    triggerClass = null;
    triggerMethod = null;
    triggerDescriptor = null;
    triggerAccess = 0;
    returnType = null;
    accessibleFields = null;
    accessibleMethods = null;
    // this is only set when the rule is created via a real installed transformer
    this.helperManager = helperManager;
    ECAGrammarParser parser = null;
    try {
      String file = getFile();
      ECATokenLexer lexer = new ECATokenLexer(new StringReader(ruleScript.getRuleText()));
      lexer.setStartLine(getLine());
      lexer.setFile(file);
      parser = new ECAGrammarParser(lexer);
      parser.setFile(file);
      Symbol parse = (debugParse ? parser.debug_parse() : parser.parse());
      if (parser.getErrorCount() != 0) {
        String message = "rule " + ruleScript.getName();
        message += parser.getErrors();
        throw new ParseException(message);
      }
      ruleTree = (ParseNode) parse.value;
    } catch (ParseException pe) {
      throw pe;
    } catch (Throwable th) {
      String message = "rule " + ruleScript.getName();
      if (parser != null && parser.getErrorCount() != 0) {
        message += parser.getErrors();
      }
      message += "\n" + th.getMessage();
      throw new ParseException(message);
    }

    ParseNode eventTree = (ParseNode) ruleTree.getChild(0);
    ParseNode conditionTree = (ParseNode) ruleTree.getChild(1);
    ParseNode actionTree = (ParseNode) ruleTree.getChild(2);

    event = Event.create(this, eventTree);
    condition = Condition.create(this, conditionTree);
    action = Action.create(this, actionTree);
    key = null;
  }
コード例 #3
0
ファイル: Rule.java プロジェクト: damc-dev/byteman
 public void setAction(String actionSpec) throws ParseException, TypeException {
   if (event != null & condition != null && action == null) {
     action = Action.create(this, actionSpec);
   }
 }
 public View getView(int position, View convertView, ViewGroup parent) {
   Action action = getItem(position);
   return action.create(mContext, convertView, parent, LayoutInflater.from(mContext));
 }