本文整理汇总了Java中gate.util.Strings类的典型用法代码示例。如果您正苦于以下问题:Java Strings类的具体用法?Java Strings怎么用?Java Strings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Strings类属于gate.util包,在下文中一共展示了Strings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setIndexer
import gate.util.Strings; //导入依赖的package包/类
/**
* Sets the Indexer to be used for indexing Datastore
*/
@Override
public void setIndexer(Indexer indexer, Map<String,Object> indexParameters)
throws IndexException {
this.indexer = indexer;
this.indexParameters = indexParameters;
this.indexURL = (URL)this.indexParameters.get(Constants.INDEX_LOCATION_URL);
this.indexer.createIndex(this.indexParameters);
// dump the version file
try {
File versionFile = getVersionFile();
OutputStreamWriter osw =
new OutputStreamWriter(new FileOutputStream(versionFile));
osw.write(versionNumber + Strings.getNl());
String indexDirRelativePath =
PersistenceManager.getRelativePath(storageDir.toURI().toURL(),
indexURL);
osw.write(indexDirRelativePath);
osw.close();
} catch(IOException e) {
throw new IndexException("couldn't write version file: " + e);
}
}
示例2: setParameterValue
import gate.util.Strings; //导入依赖的package包/类
/**
* Sets the value for a specified parameter.
*
* @param paramaterName the name for the parameteer
* @param parameterValue the value the parameter will receive
*/
@Override
public void setParameterValue(String paramaterName, Object parameterValue)
throws ResourceInstantiationException{
// get the beaninfo for the resource bean, excluding data about Object
BeanInfo resBeanInf = null;
try {
resBeanInf = Introspector.getBeanInfo(this.getClass(), Object.class);
} catch(Exception e) {
throw new ResourceInstantiationException(
"Couldn't get bean info for resource " + this.getClass().getName()
+ Strings.getNl() + "Introspector exception was: " + e
);
}
AbstractResource.setParameterValue(this, resBeanInf, paramaterName, parameterValue);
}
示例3: toString
import gate.util.Strings; //导入依赖的package包/类
/** String respresentation */
@Override
public String toString() {
String n = Strings.getNl();
StringBuffer s = new StringBuffer("DocumentImpl: " + n);
s.append(" content:" + content + n);
s.append(" defaultAnnots:" + defaultAnnots + n);
s.append(" encoding:" + encoding + n);
s.append(" features:" + features + n);
s.append(" markupAware:" + markupAware + n);
s.append(" namedAnnotSets:" + namedAnnotSets + n);
s.append(" nextAnnotationId:" + nextAnnotationId + n);
s.append(" nextNodeId:" + nextNodeId + n);
s.append(" sourceUrl:" + sourceUrl + n);
s.append(" sourceUrlStartOffset:" + sourceUrlStartOffset + n);
s.append(" sourceUrlEndOffset:" + sourceUrlEndOffset + n);
s.append(n);
return s.toString();
}
示例4: setParameterValues
import gate.util.Strings; //导入依赖的package包/类
/**
* Sets the values for more parameters for a resource in one step.
*
* @param parameters a feature map that has parameter names as keys and
* parameter values as values.
*/
public static void setParameterValues(Resource resource,
FeatureMap parameters)
throws ResourceInstantiationException{
// get the beaninfo for the resource bean, excluding data about Object
BeanInfo resBeanInf = null;
try {
resBeanInf = getBeanInfo(resource.getClass());
} catch(Exception e) {
throw new ResourceInstantiationException(
"Couldn't get bean info for resource " + resource.getClass().getName()
+ Strings.getNl() + "Introspector exception was: " + e
);
}
Iterator<Object> parnameIter = parameters.keySet().iterator();
while(parnameIter.hasNext()){
String parName = (String)parnameIter.next();
setParameterValue(resource, resBeanInf, parName, parameters.get(parName));
}
}
示例5: setParameterValue
import gate.util.Strings; //导入依赖的package包/类
/**
* Sets the value for a specified parameter for this resource.
*
* @param paramaterName the name for the parameter
* @param parameterValue the value the parameter will receive
*/
@Override
public void setParameterValue(String paramaterName, Object parameterValue)
throws ResourceInstantiationException{
// get the beaninfo for the resource bean, excluding data about Object
BeanInfo resBeanInf = null;
try {
resBeanInf = getBeanInfo(this.getClass());
} catch(Exception e) {
throw new ResourceInstantiationException(
"Couldn't get bean info for resource " + this.getClass().getName()
+ Strings.getNl() + "Introspector exception was: " + e
);
}
setParameterValue(this, resBeanInf, paramaterName, parameterValue);
}
示例6: setParameterValue
import gate.util.Strings; //导入依赖的package包/类
/**
* Sets the value for a specified parameter.
*
* @param paramaterName the name for the parameteer
* @param parameterValue the value the parameter will receive
*/
@Override
public void setParameterValue(String paramaterName, Object parameterValue)
throws ResourceInstantiationException {
// get the beaninfo for the resource bean, excluding data about
// Object
BeanInfo resBeanInf = null;
try {
resBeanInf = Introspector.getBeanInfo(this.getClass(), Object.class);
}
catch(Exception e) {
throw new ResourceInstantiationException(
"Couldn't get bean info for resource "
+ this.getClass().getName() + Strings.getNl()
+ "Introspector exception was: " + e);
}
AbstractResource.setParameterValue(this, resBeanInf, paramaterName,
parameterValue);
}
示例7: testSessionStateFileNaming
import gate.util.Strings; //导入依赖的package包/类
/** Test session state file naming */
@Test
public void testSessionStateFileNaming() throws Exception {
//TODO fix this
//again we can't test these thinfs if there is no file to test
if (Gate.getUserConfigFile() == null) return;
String fileSep = Strings.getFileSep();
if(DEBUG) {
Out.prln("file sep is: " + fileSep);
}
if(Gate.runningOnUnix()) {
assertTrue(fileSep.equals("/"));
assertTrue(
Gate.getUserSessionFile().toString().endsWith("."+GateConstants.GATE_DOT_SER)
);
} else {
assertTrue(! fileSep.equals("/"));
assertTrue(
! Gate.getUserSessionFile().toString().endsWith("."+GateConstants.GATE_DOT_SER)
);
}
}
示例8: testConfigFileNaming
import gate.util.Strings; //导入依赖的package包/类
/** Test config file naming */
public void testConfigFileNaming() throws Exception {
String fileSep = Strings.getFileSep();
if(DEBUG) {
Out.prln("file sep is: " + fileSep);
}
if(Gate.runningOnUnix()) {
assertTrue(fileSep.equals("/"));
assertTrue(
Gate.getDefaultUserConfigFileName().endsWith("."+GateConstants.GATE_DOT_XML)
);
} else {
assertTrue(! fileSep.equals("/"));
assertTrue(
! Gate.getDefaultUserConfigFileName().endsWith("."+GateConstants.GATE_DOT_XML)
);
}
}
示例9: create
import gate.util.Strings; //导入依赖的package包/类
/** Create a new data store. This tries to create a directory in
* the local file system. If the directory already exists and is
* non-empty, or is
* a file, or cannot be created, PersistenceException is thrown.
*/
@Override
public void create()
throws PersistenceException {
if(storageDir == null)
throw new PersistenceException("null storage directory: cannot create");
if(! storageDir.exists()) { // if doesn't exist create it
if(! storageDir.mkdir())
throw new
PersistenceException("cannot create directory " + storageDir);
} else { // must be empty
String[] existingFiles = filterIgnoredFileNames(storageDir.list());
if(! (existingFiles == null || existingFiles.length == 0) )
throw new PersistenceException(
"directory "+ storageDir +" is not empty: cannot use for data store"
);
}
// dump the version file
try {
File versionFile = getVersionFile();
OutputStreamWriter osw = new OutputStreamWriter(
new FileOutputStream(versionFile)
);
osw.write(versionNumber + Strings.getNl());
osw.close();
} catch(IOException e) {
throw new PersistenceException("couldn't write version file: " + e);
}
}
示例10: toString
import gate.util.Strings; //导入依赖的package包/类
/** String representation */
@Override
public String toString() {
String nl = Strings.getNl();
StringBuffer s = new StringBuffer("SerialDataStore: ");
s.append("autoSaving: " + autoSaving);
s.append("; storageDir: " + storageDir);
s.append(nl);
return s.toString();
}
示例11: getDefaultUserConfigFileName
import gate.util.Strings; //导入依赖的package包/类
/**
* Get the default path to the user's config file, which is used unless an
* alternative name has been specified via system properties or
* {@link #setUserConfigFile}.
*
* @return the default user config file path.
*/
public static String getDefaultUserConfigFileName() {
String filePrefix = "";
if(runningOnUnix()) filePrefix = ".";
String userConfigName =
System.getProperty("user.home") + Strings.getFileSep() + filePrefix
+ GATE_DOT_XML;
return userConfigName;
}
示例12: getDefaultUserSessionFileName
import gate.util.Strings; //导入依赖的package包/类
/**
* Get the default path to the user's session file, which is used unless an
* alternative name has been specified via system properties or
* {@link #setUserSessionFile(File)}
*
* @return the default user session file path.
*/
public static String getDefaultUserSessionFileName() {
String filePrefix = "";
if(runningOnUnix()) filePrefix = ".";
String userSessionName =
System.getProperty("user.home") + Strings.getFileSep() + filePrefix
+ GATE_DOT_SER;
return userSessionName;
}
示例13: help
import gate.util.Strings; //导入依赖的package包/类
/** Display a help message */
public static void help() {
String nl = Strings.getNl();
Out.prln(
"For help on command-line options and other information " + nl +
"see the user manual in your GATE distribution or at " + nl +
"http://gate.ac.uk/userguide/"
);
}
示例14: endDocument
import gate.util.Strings; //导入依赖的package包/类
/** Called when the SAX parser encounts the end of the XML document */
@Override
public void endDocument() throws GateSaxException {
if(DEBUG) Out.prln("end document");
if(! contentStack.isEmpty()) {
StringBuffer errorMessage =
new StringBuffer("document ended but element stack not empty:");
while(! contentStack.isEmpty())
errorMessage.append(Strings.getNl()+" "+contentStack.pop());
throw new GateSaxException(errorMessage.toString());
}
}
示例15: getParameterClass
import gate.util.Strings; //导入依赖的package包/类
/** Find the class for this parameter type. */
protected Class<?> getParameterClass() throws ParameterException
{
// get java builtin classes via class; else look in the register
try {
ResourceData resData = Gate.getCreoleRegister().get(typeName);
if(resData == null){
paramClass = Gate.getClassLoader().loadClass(typeName);
}else{
paramClass = resData.getResourceClass();
}
// if(typeName.startsWith("java."))
// paramClass = Class.forName(typeName);
// else {
// ResourceData resData =
// (ResourceData) Gate.getCreoleRegister().get(typeName);
// if(resData == null)
// throw new ParameterException(
// "No resource data for " + typeName + " in Parameter/getParamClz"
// );
// paramClass = resData.getResourceClass();
// }
} catch(ClassNotFoundException e) {
throw new ParameterException(
"Couldn't find class " + typeName + ": " + Strings.getNl() + e
);
}
if(paramClass == null)
throw new ParameterException("Couldn't find class " + typeName);
return paramClass;
}