当前位置: 首页>>代码示例>>Java>>正文


Java FileUtils.guessLang方法代码示例

本文整理汇总了Java中com.hp.hpl.jena.util.FileUtils.guessLang方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.guessLang方法的具体用法?Java FileUtils.guessLang怎么用?Java FileUtils.guessLang使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.hp.hpl.jena.util.FileUtils的用法示例。


在下文中一共展示了FileUtils.guessLang方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initializeReasoner

import com.hp.hpl.jena.util.FileUtils; //导入方法依赖的package包/类
protected void initializeReasoner() throws ConfigurationException {
	if (isConfigurationStale()) {
		// read in a new config model
		setConfigModel(ModelFactory.createDefaultModel());
		getConfigModel().setNsPrefix("", CONFIG_NAMESPACE);
		String configFilename = null;
		try {
			configFilename = getConfigurationFilename();
			File configFile = new File(configFilename);
			if (configFile.exists()) {
				// load configuration info from file
				String syntax = FileUtils.guessLang(configFilename);
				FileInputStream in = new FileInputStream(configFile);
				getConfigModel().read(in, null, syntax);
				timeConfigFileLastModifiedAtInitialization = configFile
						.lastModified();
				in.close();
			} else {
				throw new ConfigurationException("Configuration file '"
						+ configFilename + "' not found.");
			}
		} catch (IOException e) {
			throw new ConfigurationException(
					"Exception getting configuration from file: "
							+ e.getMessage());
		}
	}
	super.initializeReasoner();
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:30,代码来源:ConfigurationManagerForEditing.java

示例2: initializeReasoner

import com.hp.hpl.jena.util.FileUtils; //导入方法依赖的package包/类
protected void initializeReasoner() throws ConfigurationException {
	if (isConfigurationStale()) {
		// read in a new config model
		setConfigModel(ModelFactory.createDefaultModel());
		getConfigModel().setNsPrefix("", CONFIG_NAMESPACE);
		String configFilename = null;
		try {
			configFilename = getConfigurationFilename();
			File configFile = new File(configFilename);
			if (configFile.exists()) {
				// load configuration info from file
				String syntax = FileUtils.guessLang(configFilename);
				FileInputStream in = new FileInputStream(configFile);
				getConfigModel().read(in, null, syntax);
				timeConfigFileLastModifiedAtInitialization = configFile
						.lastModified();
			} else {
				throw new ConfigurationException("Configuration file '"
						+ configFilename + "' not found.");
			}
		} catch (IOException e) {
			throw new ConfigurationException(
					"Exception getting configuration from file: "
							+ e.getMessage());
		}
	}
	super.initializeReasoner();
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:29,代码来源:ConfigurationManagerForEditing.java

示例3: loadConfigurationFile

import com.hp.hpl.jena.util.FileUtils; //导入方法依赖的package包/类
private void loadConfigurationFile() throws ConfigurationException {
	if (getModelFolderPath() != null) {
		String modelFolderPathname = getModelFolderPath().getAbsolutePath();
		String configFilename;
		try {
			configFilename = getModelFolderPath().getCanonicalPath() + File.separator + CONFIG_FILENAME;
			File configFile = new File(configFilename);
			if (configFile.exists()) {
				// load configuration info from file
	            String syntax = FileUtils.guessLang(configFilename);
	            FileInputStream in = new FileInputStream(configFile);
	            getConfigModel().read( in, null, syntax );
	            if (!getConfigModel().contains(getConfigModel().getResource(CONFIG_NAMESPACE + BuiltinCategory), RDF.type, getConfigModel().getResource(CATEGORY_KW))) {
	            	// this statement must be there to find built-ins but seems to disappear from time to time--this is a workaround
	            	getConfigModel().add(getConfigModel().getResource(CONFIG_NAMESPACE + BuiltinCategory), RDF.type, getConfigModel().getResource(CATEGORY_KW));
	            }
	            Resource df = getConfigModel().getResource(CONFIG_NAMESPACE + DateFormat);
	            Property dmyp = getConfigModel().getProperty(CONFIG_NAMESPACE + dmyOrder);
	            Statement stmt = getConfigModel().getProperty(df, dmyp);
	            if (stmt != null) {
	            	String val = stmt.getObject().asLiteral().getLexicalForm();
	            	if (val.equals(IConfigurationManager.dmyOrderDMY)) {
	            		DateTimeConfig.getGlobalDefault().setDmyOrder(true);
	            	}
	            	else {
	            		DateTimeConfig.getGlobalDefault().setDmyOrder(false);
	            	}
	            }
	            in.close();
			}
			else {
				logger.warn("Model folder '" + modelFolderPathname + "' has no configuration file.");
			}
		} catch (IOException e) {
			e.printStackTrace();
			throw new ConfigurationException("Failed to load configuration file", e);
		}
	}
	else if (getModelFolderUrl() != null) {
		getConfigModel().read(getModelFolderUrl() + "/" + CONFIG_FILENAME);
	}
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:43,代码来源:ConfigurationManager.java

示例4: loadConfigurationFile

import com.hp.hpl.jena.util.FileUtils; //导入方法依赖的package包/类
private void loadConfigurationFile() throws ConfigurationException {
	if (getModelFolderPath() != null) {
		String modelFolderPathname = getModelFolderPath().getAbsolutePath();
		String configFilename;
		try {
			configFilename = getModelFolderPath().getCanonicalPath() + File.separator + CONFIG_FILENAME;
			File configFile = new File(configFilename);
			if (configFile.exists()) {
				// load configuration info from file
	            String syntax = FileUtils.guessLang(configFilename);
	            FileInputStream in = new FileInputStream(configFile);
	            getConfigModel().read( in, null, syntax );
	            if (!getConfigModel().contains(getConfigModel().getResource(CONFIG_NAMESPACE + BuiltinCategory), RDF.type, getConfigModel().getResource(CATEGORY_KW))) {
	            	// this statement must be there to find built-ins but seems to disappear from time to time--this is a workaround
	            	getConfigModel().add(getConfigModel().getResource(CONFIG_NAMESPACE + BuiltinCategory), RDF.type, getConfigModel().getResource(CATEGORY_KW));
	            }
	            Resource df = getConfigModel().getResource(CONFIG_NAMESPACE + DateFormat);
	            Property dmyp = getConfigModel().getProperty(CONFIG_NAMESPACE + dmyOrder);
	            Statement stmt = getConfigModel().getProperty(df, dmyp);
	            if (stmt != null) {
	            	String val = stmt.getObject().asLiteral().getLexicalForm();
	            	if (val.equals(IConfigurationManager.dmyOrderDMY)) {
	            		DateTimeConfig.getGlobalDefault().setDmyOrder(true);
	            	}
	            	else {
	            		DateTimeConfig.getGlobalDefault().setDmyOrder(false);
	            	}
	            }
			}
			else {
				logger.warn("Model folder '" + modelFolderPathname + "' has no configuration file.");
			}
		} catch (IOException e) {
			e.printStackTrace();
			throw new ConfigurationException("Failed to load configuration file", e);
		}
	}
	else if (getModelFolderUrl() != null) {
		getConfigModel().read(getModelFolderUrl() + "/" + CONFIG_FILENAME);
	}
}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:42,代码来源:ConfigurationManager.java

示例5: getLanguage

import com.hp.hpl.jena.util.FileUtils; //导入方法依赖的package包/类
protected String getLanguage( Resource root, File fullName )
{
Statement s = getUniqueStatement( root, JA.fileEncoding );
return s == null ? FileUtils.guessLang( fullName.toString() ) : getString( s );
}
 
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:6,代码来源:FileModelAssembler.java

示例6: FileGraph

import com.hp.hpl.jena.util.FileUtils; //导入方法依赖的package包/类
/**
    Construct a new FileGraph who's name is given by the specified File,
    If create is true, this is a new file, and any existing file will be destroyed;
    if create is false, this is an existing file, and its current contents will
    be loaded. The language code for the file is guessed from its suffix.
    
 	@param f the File naming the associated file-system file
 	@param create true to create a new one, false to read an existing one
    @param strict true to throw exceptions for create: existing, open: not found
    @param style the reification style for the graph
*/
public FileGraph( NotifyOnClose notify, File f, boolean create, boolean strict, ReificationStyle style )
    { this( notify, f, FileUtils.guessLang( f.toString() ), create, strict, style ); }
 
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:14,代码来源:FileGraph.java

示例7: isPlausibleGraphName

import com.hp.hpl.jena.util.FileUtils; //导入方法依赖的package包/类
/**
    Answer true iff the filename string given is plausibly the name of a 
    graph, ie, may have RDF content. We appeal to FileUtils - if it can 
    guess an RDF language name, we deliver true, otherwise false.
    
 	@param name the leaf component of a filename
 	@return true if it is likely to be an RDF file
*/
public static boolean isPlausibleGraphName( String name )
    { return FileUtils.guessLang( name, null ) != null; }
 
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:11,代码来源:FileGraph.java


注:本文中的com.hp.hpl.jena.util.FileUtils.guessLang方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。