コード例 #1
0
 public boolean isChildOf(Keyword word) {
   Iterator parents = getParentIterator();
   while (parents.hasNext()) {
     Keyword par = (Keyword) parents.next();
     if (par == null) return (false);
     else if (par.equals(word)) return (true);
     else return (par.isChildOf(word));
   }
   return false;
 }
コード例 #2
0
ファイル: Console.java プロジェクト: disjunction/ludus
	public void processLine(String line) throws Exception {
		line = line.trim();
		if (line.length() > 0 && line.substring(0, 1).equals("#")) {
			return;
		}
		String[] chunks = line.split(" ");
		String command = chunks[0];
		
		String[] params = new String[chunks.length -1];
		for (int i = 1; i< chunks.length; i++) {
			params[i - 1] = chunks[i];
		}
		
		switch (Keyword.toKeyword(command)) {
			case q:
			case quit:
				throw new RuntimeException("quit!");
			case trans:
			case t:
				translateSpelling(params[0]);
				break;
			case h:
			case help:
				InputStream stream = Console.class.getResourceAsStream("ConsoleHelp.txt");
				BufferedReader in = new BufferedReader(new InputStreamReader(stream));
				String tmpLine = null;
				while((tmpLine = in.readLine()) != null) out(tmpLine);
				stream.close();
				break;
			default:
				throw new RuntimeException("unknown command " + command);
		}
	}
コード例 #3
0
 public static EnumDefinition dropKeywordCreateEnum(
     EnumDefinition enumDefinition, Keyword keyword, boolean saveEnum) {
   if (enumDefinition == null) {
     enumDefinition = new EnumDefinition(keyword.toString(), saveEnum);
   }
   enumDefinition.setKeyword(keyword);
   return enumDefinition;
 }
コード例 #4
0
  public static Vector extractKeywordFromText(String text) {
    // see if there are any existing keywords represented
    // in this text
    // Get all keywords

    Vector extractedKeywords = new Vector();
    Iterator keywords = allKeywords.iterator();
    while (keywords.hasNext()) {
      Keyword keyword = (Keyword) keywords.next();
      if (text != null
          && keyword.toString() != null
          && text.toLowerCase().indexOf(keyword.toString().toLowerCase()) > -1) {
        extractedKeywords.addElement(keyword);
      }
    }
    return extractedKeywords;
  }
コード例 #5
0
 public UndefinedBooleanExpressionPanel(UndefinedBooleanExpression expr) {
   setLayout(new FlowLayout(FlowLayout.LEFT));
   setBackground(Color.white);
   // setBorder
   //		 (BorderFactory.createLineBorder(Color.red,
   //																								2));
   if (expr.getLeftHandSide() instanceof Keyword
       && expr.getRightHandSide() instanceof EnumLevelList) {
     Keyword keyword = (Keyword) expr.getLeftHandSide();
     EnumLevelList ll = (EnumLevelList) expr.getRightHandSide();
     // System.out.println("keyword " + keyword);
     JLabel keywordLabel = new JLabel(keyword.toString() + ARROW);
     // keywordLabel.setFont(new Font("Arial",10,Font.BOLD));
     add(keywordLabel);
     if (ll.isNumericList()) add(getNumericLevels(ll));
     else add(getStringLevels(ll));
   } else add(new JLabel("Improperly defined boolean expression"));
 }
コード例 #6
0
 private Vector getChildren(Keyword keyword, Vector allKids) {
   allKids.addElement(keyword);
   // 			System.out.println("Addtoallkids " + keyword + "  " + allKids );
   Vector children = keyword.getChildren();
   if (children != null) {
     Iterator i = children.iterator();
     while (i.hasNext()) {
       Keyword child = (Keyword) i.next();
       getChildren(child, allKids);
     }
   }
   return allKids;
 }
コード例 #7
0
  public boolean dropOn(Object dropOnObject) {
    if (dropOnObject instanceof Keyword) {
      Keyword parentKeyword = null;
      Keyword newParentKeyword = (Keyword) dropOnObject;
      // Add child to new parent
      newParentKeyword.addChild(this);
      // Add new parent to child
      setPar(newParentKeyword);
      update();
      newParentKeyword.update();
      return true;
    } else if (dropOnObject instanceof PersistibleWithKeywords) {
      // 						System.out.println("droping a keyword on " + dropOnObject);
      // THis seems to cause a duplicate entry
      addDescribedInstance((PersistibleWithKeywords) dropOnObject);
      update();

      ((PersistibleWithKeywords) dropOnObject).link(this);
      ((PersistibleWithKeywords) dropOnObject).update();
      return true;
    }
    return false;
  }
コード例 #8
0
  private void addKeyword(Hashtable table, Keyword word, Keyword parent) {
    boolean recurse = true;

    if (table.containsKey(word)) recurse = false;

    if (parent == null) table.put(word, String.valueOf(-1));
    else table.put(word, parent);

    if (recurse) {
      Iterator it = word.getChildren().iterator();
      while (it.hasNext()) {
        addKeyword(table, (Keyword) it.next(), word);
      }
    }
  }
コード例 #9
0
 public static EnumDefinition dropKeywordCreateEnum(Keyword keyword, boolean saveEnum) {
   EnumDefinition enumDefinition = new EnumDefinition(keyword.toString(), saveEnum);
   enumDefinition.setKeyword(keyword);
   return enumDefinition;
 }
コード例 #10
0
 public static void main(String[] args) {
   Keyword t = new Keyword("TEST KEYWORD");
   t.update();
   oncotcap.Oncotcap.getDataSource().commit();
 }