001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.java.preprocessorbridge.spi;
043:
044: import java.io.Reader;
045: import java.io.Writer;
046: import javax.swing.event.ChangeListener;
047:
048: /**
049: * This interface in a friend contract among the j2me project and java/source
050: * module. The implementation preprocesses the java file content when it's red by the
051: * java infrastructure if needed. From the performance reasons there can be just one
052: * implementation of this interface for all sources in the project.
053: *
054: * @author Tomas Zezula
055: */
056: public interface JavaFileFilterImplementation {
057:
058: /**
059: * Filters an {@link Reader} by the preprocessor.
060: * Called when the file is read from the disk before its content is passed to javac.
061: * PRE: The input parameter is never null
062: * POST: The returned Reader is not null
063: * Threading: The implementor is responsible for concurrent safety, tail call hand off protocol is suggested.
064: * @param r {@link Reader} to be preprocessed
065: * @return an preprocessed {@link Reader}
066: */
067: public Reader filterReader(Reader r);
068:
069: /**
070: * Filters an input {@link CharSequence} by the preprocessor. From the performance reason
071: * it's highly recommended to implement the method using decorator pattern.
072: * Called before the content of the editor is passed to the javac.
073: * PRE: The input parameter is never null
074: * POST: The returned CharSequence is not null
075: * Threading: The implementor is responsible for concurrent safety, tail call hand off protocol is suggested.
076: * @param charSequence {@link CharSequence} to be preprocessed
077: * @return an preprocessed {@link CharSequence}
078: */
079: public CharSequence filterCharSequence(CharSequence charSequence);
080:
081: /**
082: * Filters an {@link Writer} by the preprocessor.
083: * Called before the file is written to the disk.
084: * PRE: The input parameter is never null
085: * POST: The returned Writer is not null
086: * Threading: The implementor is responsible for concurrent safety, tail call hand off protocol is suggested.
087: * @param w {@link Writer} to be preprocessed
088: * @return an preprocessed {@link Writer}
089: */
090: public Writer filterWriter(Writer w);
091:
092: /**
093: * Adds an {@link ChangeListener} to the {@link JavaFileFilterImplementation}
094: * The implementor should fire a change when the rules for preprocessing has changed
095: * and files should be rescanned.
096: * @param listener to be added
097: */
098: public void addChangeListener(ChangeListener listener);
099:
100: /**
101: * Removes an {@link ChangeListener} to the {@link JavaFileFilterImplementation}
102: * The implementor should fire a change when the rules for preprocessing has changed
103: * and files should be rescanned.
104: * @param listener to be removed
105: */
106: public void removeChangeListener(ChangeListener listener);
107: }
|