Exemplo n.º 1
0
 void open(java.lang.String name) {
   final java.lang.String textString;
   if (name == null || name.length() == 0) {
     return;
   }
   java.io.File file = new java.io.File(name);
   if (!file.exists()) {
     java.lang.String message =
         MessageFormat.format(
             resources.getString("Err_file_no_exist"), new java.lang.String[] {file.getName()});
     displayError(message);
     return;
   }
   try {
     java.io.FileInputStream stream = new java.io.FileInputStream(file.getPath());
     try {
       java.io.Reader in = new java.io.BufferedReader(new java.io.InputStreamReader(stream));
       char[] readBuffer = new char[2048];
       java.lang.StringBuffer buffer = new java.lang.StringBuffer((int) file.length());
       int n;
       while ((n = in.read(readBuffer)) > 0) {
         buffer.append(readBuffer, 0, (-n));
       }
       textString = buffer.toString();
       stream.close();
     } catch (java.io.IOException e) {
       java.lang.String message =
           MessageFormat.format(
               resources.getString("Err_file_io"), new java.lang.String[] {file.getName()});
       displayError(message);
       return;
     }
   } catch (java.io.FileNotFoundException e) {
     java.lang.String message =
         MessageFormat.format(
             resources.getString("Err_not_found"), new java.lang.String[] {file.getName()});
     displayError(message);
     return;
   }
   org.eclipse.swt.widgets.Display display = text.getDisplay();
   display.asyncExec(
       new java.lang.Runnable() {
         public void run() {
           text.setText(textString);
         }
       });
   lineStyler.parseBlockComments(textString);
 }
Exemplo n.º 2
0
  public boolean contains(java.io.Reader in) throws java.io.IOException {
    if (this.startState == null) return false;
    State state = this.states[this.startState.intValue()];

    loop:
    for (int ch = in.read(); ch != -1; ch = in.read()) {
      for (int i = 0; i < state.transitions.length; ++i) {
        if (state.transitions[i].charSet.contains((char) ch)) {
          state = this.states[state.transitions[i].toState];
          continue loop;
        }
      }
      return false;
    }

    return state.isFinal;
  }
Exemplo n.º 3
0
 public void setCharacterStream(int parameterIndex, java.io.Reader reader, int length)
     throws SQLException {
   try {
     char[] data = new char[length];
     reader.read(data);
     setString(parameterIndex, new String(data));
   } catch (java.io.IOException e) {
     throw new SQLException("I/O failed");
   }
 }