mirror of
https://github.com/SuspiciousActivity/ByteEdit.git
synced 2026-08-13 17:56:17 +00:00
Added code folding and formatted all files
This commit is contained in:
1 parent
11570d6b95
commit
66cd1dbd3e
233 files changed
+82245
-118134
No files matched your search
@@ -1,9 +1,7 @@
|
||||
/*
|
||||
* 12/14/08
|
||||
*
|
||||
* AbstractTokenMakerFactory.java - Base class for TokenMaker implementations.
|
||||
*
|
||||
* This library is distributed under a modified BSD license. See the included
|
||||
* This library is distributed under a modified BSD license. See the included
|
||||
* RSyntaxTextArea.License.txt file for details.
|
||||
*/
|
||||
package org.fife.ui.rsyntaxtextarea;
|
||||
@@ -12,25 +10,23 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* Base class for {@link TokenMakerFactory} implementations. A mapping from
|
||||
* Base class for {@link TokenMakerFactory} implementations. A mapping from
|
||||
* language keys to the names of {@link TokenMaker} classes is stored.
|
||||
*
|
||||
* @author Robert Futrell
|
||||
* @version 1.0
|
||||
*/
|
||||
public abstract class AbstractTokenMakerFactory extends TokenMakerFactory {
|
||||
|
||||
|
||||
/**
|
||||
* A mapping from keys to the names of {@link TokenMaker} implementation
|
||||
* class names. When {@link #getTokenMaker(String)} is called with a key
|
||||
* class names. When {@link #getTokenMaker(String)} is called with a key
|
||||
* defined in this map, a <code>TokenMaker</code> of the corresponding type
|
||||
* is returned.
|
||||
*/
|
||||
private Map<String, Object> tokenMakerMap;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
@@ -38,19 +34,19 @@ public abstract class AbstractTokenMakerFactory extends TokenMakerFactory {
|
||||
tokenMakerMap = new HashMap<String, Object>();
|
||||
initTokenMakerMap();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns a {@link TokenMaker} for the specified key.
|
||||
*
|
||||
* @param key The key.
|
||||
* @param key
|
||||
* The key.
|
||||
* @return The corresponding <code>TokenMaker</code>, or <code>null</code>
|
||||
* if none matches the specified key.
|
||||
*/
|
||||
@Override
|
||||
protected TokenMaker getTokenMakerImpl(String key) {
|
||||
TokenMakerCreator tmc = (TokenMakerCreator)tokenMakerMap.get(key);
|
||||
if (tmc!=null) {
|
||||
TokenMakerCreator tmc = (TokenMakerCreator) tokenMakerMap.get(key);
|
||||
if (tmc != null) {
|
||||
try {
|
||||
return tmc.create();
|
||||
} catch (RuntimeException re) { // FindBugs
|
||||
@@ -61,11 +57,10 @@ public abstract class AbstractTokenMakerFactory extends TokenMakerFactory {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Populates the mapping from keys to instances of
|
||||
* <code>TokenMakerCreator</code>s. Subclasses should override this method
|
||||
* <code>TokenMakerCreator</code>s. Subclasses should override this method
|
||||
* and call one of the <code>putMapping</code> overloads to register
|
||||
* {@link TokenMaker}s for syntax constants.
|
||||
*
|
||||
@@ -73,8 +68,7 @@ public abstract class AbstractTokenMakerFactory extends TokenMakerFactory {
|
||||
* @see #putMapping(String, String, ClassLoader)
|
||||
*/
|
||||
protected abstract void initTokenMakerMap();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -82,53 +76,52 @@ public abstract class AbstractTokenMakerFactory extends TokenMakerFactory {
|
||||
public Set<String> keySet() {
|
||||
return tokenMakerMap.keySet();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adds a mapping from a key to a <code>TokenMaker</code> implementation
|
||||
* class name.
|
||||
*
|
||||
* @param key The key.
|
||||
* @param className The <code>TokenMaker</code> class name.
|
||||
* @param key
|
||||
* The key.
|
||||
* @param className
|
||||
* The <code>TokenMaker</code> class name.
|
||||
* @see #putMapping(String, String, ClassLoader)
|
||||
*/
|
||||
public void putMapping(String key, String className) {
|
||||
putMapping(key, className, null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adds a mapping from a key to a <code>TokenMaker</code> implementation
|
||||
* class name.
|
||||
*
|
||||
* @param key The key.
|
||||
* @param className The <code>TokenMaker</code> class name.
|
||||
* @param cl The class loader to use when loading the class.
|
||||
* @param key
|
||||
* The key.
|
||||
* @param className
|
||||
* The <code>TokenMaker</code> class name.
|
||||
* @param cl
|
||||
* The class loader to use when loading the class.
|
||||
* @see #putMapping(String, String)
|
||||
*/
|
||||
public void putMapping(String key, String className, ClassLoader cl) {
|
||||
tokenMakerMap.put(key, new TokenMakerCreator(className, cl));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Wrapper that handles the creation of TokenMaker instances.
|
||||
*/
|
||||
private static class TokenMakerCreator {
|
||||
|
||||
|
||||
private String className;
|
||||
private ClassLoader cl;
|
||||
|
||||
|
||||
public TokenMakerCreator(String className, ClassLoader cl) {
|
||||
this.className = className;
|
||||
this.cl = cl!=null ? cl : getClass().getClassLoader();
|
||||
this.cl = cl != null ? cl : getClass().getClassLoader();
|
||||
}
|
||||
|
||||
|
||||
public TokenMaker create() throws Exception {
|
||||
return (TokenMaker)Class.forName(className, true, cl).newInstance();
|
||||
return (TokenMaker) Class.forName(className, true, cl).newInstance();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user