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


Java DISIException类代码示例

本文整理汇总了Java中it.unitn.disi.common.DISIException的典型用法代码示例。如果您正苦于以下问题:Java DISIException类的具体用法?Java DISIException怎么用?Java DISIException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getDictionary

import it.unitn.disi.common.DISIException; //导入依赖的package包/类
public static Dictionary getDictionary(String jwnlPropertiesPath) throws SMatchException {
    try {
        if (null != jwnlPropertiesPath) {
            log.info("Initializing extJWNL (" + jwnlPropertiesPath + ")");

            InputStream is = MiscUtils.getInputStream(jwnlPropertiesPath);
            try {
                return Dictionary.getInstance(is);
            } finally {
                if (null != is) {
                    is.close();
                }
            }
        } else {
            log.info("Initializing extJWNL (default resource instance)");
            return Dictionary.getDefaultResourceInstance();
        }
    } catch (JWNLException | DISIException | IOException e) {
        throw new SMatchException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
    }
}
 
开发者ID:s-match,项目名称:s-match-wordnet,代码行数:22,代码来源:WordNet.java

示例2: readObject

import it.unitn.disi.common.DISIException; //导入依赖的package包/类
/**
 * Reads Java object from url.
 * Recognizes classpath:// prefix in <code>url</code> to load from classpath.
 * Treats url as a filename if url scheme marker (<code>://</code>) is absent.
 *
 * @param url object location
 * @return the object
 * @throws DISIException DISIException
 */
public static Object readObject(String url) throws DISIException {
    if (log.isDebugEnabled()) {
        log.debug("Reading: " + url);
    }
    Object result;

    try (InputStream is = getInputStream(url);
         BufferedInputStream bis = new BufferedInputStream(is);
         ObjectInputStream oos = new ObjectInputStream(bis)) {
        result = oos.readObject();
    } catch (IOException | ClassNotFoundException e) {
        throw new DISIException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
    }
    return result;
}
 
开发者ID:s-match,项目名称:s-match-core,代码行数:25,代码来源:MiscUtils.java

示例3: getInputStream

import it.unitn.disi.common.DISIException; //导入依赖的package包/类
/**
 * Returns <code>InputStream</code> as in {@link java.net.URL#openStream()}, but supports also
 * "classpath://" scheme.
 *
 * @param url resource location
 * @return InputStream instance
 */
public static InputStream getInputStream(String url) throws DISIException {
    InputStream result;
    try {
        if (url.startsWith(CLASSPATH_SCHEME)) {
            String cpLocation = url.substring(CLASSPATH_SCHEME.length());
            result = Thread.currentThread().getContextClassLoader().getResourceAsStream(cpLocation);
        } else {
            if (url.contains("://")) {
                result = new URL(url).openStream();
            } else {
                result = new FileInputStream(url);
            }
        }
    } catch (IOException e) {
        throw new DISIException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
    }
    return result;
}
 
开发者ID:s-match,项目名称:s-match-core,代码行数:26,代码来源:MiscUtils.java

示例4: getOutputStream

import it.unitn.disi.common.DISIException; //导入依赖的package包/类
/**
 * Returns <code>OutputStream</code> as in {@link java.net.URL#openStream()}, but supports also
 * "classpath://" scheme.
 *
 * @param url resource location
 * @return InputStream instance
 */
public static OutputStream getOutputStream(String url) throws DISIException {
    OutputStream result;
    try {
        if (url.startsWith(CLASSPATH_SCHEME)) {
            String cpLocation = url.substring(CLASSPATH_SCHEME.length());
            URL location = Thread.currentThread().getContextClassLoader().getResource(cpLocation);
            if (null != location) {
                result = location.openConnection().getOutputStream();
            } else {
                throw new DISIException("Resource is not found: " + url);
            }
        } else {
            if (url.contains("://")) {
                result = new URL(url).openConnection().getOutputStream();
            } else {
                result = new FileOutputStream(url);
            }
        }
    } catch (IOException e) {
        throw new DISIException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
    }
    return result;
}
 
开发者ID:s-match,项目名称:s-match-core,代码行数:31,代码来源:MiscUtils.java

示例5: writeMultiwords

import it.unitn.disi.common.DISIException; //导入依赖的package包/类
private static void writeMultiwords(Dictionary dic, String multiwordsFileName) throws SMatchException {
    try {
        MiscUtils.writeObject(createMultiwordHash(dic), multiwordsFileName);
    } catch (DISIException e) {
        throw new SMatchException(e.getMessage(), e);
    }
}
 
开发者ID:s-match,项目名称:s-match-wordnet,代码行数:8,代码来源:WordNet.java

示例6: readHash

import it.unitn.disi.common.DISIException; //导入依赖的package包/类
private static long[] readHash(String fileName) throws SMatchException {
    try {
        return (long[]) MiscUtils.readObject(fileName);
    } catch (DISIException e) {
        throw new SMatchException(e.getMessage(), e);
    }
}
 
开发者ID:s-match,项目名称:s-match-wordnet,代码行数:8,代码来源:InMemoryWordNetBinaryArray.java

示例7: convertAndWrite

import it.unitn.disi.common.DISIException; //导入依赖的package包/类
private static void convertAndWrite(Set<Long> keys, String fileName) throws SMatchException {
    try {
        long[] keysArr = new long[keys.size()];
        int i = 0;
        for (Long key : keys) {
            keysArr[i] = key;
            i++;
        }
        Arrays.sort(keysArr);
        MiscUtils.writeObject(keysArr, fileName);
    } catch (DISIException e) {
        throw new SMatchException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
    }
}
 
开发者ID:s-match,项目名称:s-match-wordnet,代码行数:15,代码来源:InMemoryWordNetBinaryArray.java

示例8: writeObject

import it.unitn.disi.common.DISIException; //导入依赖的package包/类
/**
 * Writes Java object to url.
 * Recognizes classpath:// prefix in <code>url</code> to write to classpath (hypothetically :).
 * Treats url as a filename if url scheme marker (<code>://</code>) is absent.
 *
 * @param object the object
 * @param url    object location
 * @throws DISIException DISIException
 */
public static void writeObject(Object object, String url) throws DISIException {
    if (log.isDebugEnabled()) {
        log.debug("Writing: " + url);
    }

    try (OutputStream os = getOutputStream(url);
         BufferedOutputStream bos = new BufferedOutputStream(os);
         ObjectOutputStream oos = new ObjectOutputStream(bos)) {
        oos.writeObject(object);
    } catch (IOException e) {
        throw new DISIException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
    }
}
 
开发者ID:s-match,项目名称:s-match-core,代码行数:23,代码来源:MiscUtils.java

示例9: writeMultiwords

import it.unitn.disi.common.DISIException; //导入依赖的package包/类
private static void writeMultiwords(Properties properties) throws SMatchException {
    log.info("Creating multiword hash...");
    HashMap<String, ArrayList<ArrayList<String>>> multiwords = new HashMap<String, ArrayList<ArrayList<String>>>();
    POS[] parts = new POS[]{POS.NOUN, POS.ADJECTIVE, POS.VERB, POS.ADVERB};
    for (POS pos : parts) {
        collectMultiwords(multiwords, pos);
    }
    log.info("Multiwords: " + multiwords.size());
    try {
        MiscUtils.writeObject(multiwords, properties.getProperty(MULTIWORDS_FILE_KEY));
    } catch (DISIException e) {
        throw new SMatchException(e.getMessage(), e);
    }
}
 
开发者ID:opendatatrentino,项目名称:s-match,代码行数:15,代码来源:WordNet.java

示例10: readHash

import it.unitn.disi.common.DISIException; //导入依赖的package包/类
private static long[] readHash(String fileName, boolean isInternalFile) throws SMatchException {
    try {
        return (long[]) MiscUtils.readObject(fileName, isInternalFile);
    } catch (DISIException e) {
        throw new SMatchException(e.getMessage(), e);
    }
}
 
开发者ID:opendatatrentino,项目名称:s-match,代码行数:8,代码来源:InMemoryWordNetBinaryArray.java

示例11: writeObject

import it.unitn.disi.common.DISIException; //导入依赖的package包/类
/**
 * Writes Java object to a file.
 *
 * @param object   the object
 * @param fileName the file where the object will be written
 * @throws DISIException DISIException
 */
public static void writeObject(Object object, String fileName) throws DISIException {
    log.info("Writing " + fileName);
    try {
        FileOutputStream fos = new FileOutputStream(fileName);
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        oos.writeObject(object);
        oos.close();
        fos.close();
    } catch (IOException e) {
        final String errMessage = e.getClass().getSimpleName() + ": " + e.getMessage();
        log.error(errMessage, e);
        throw new DISIException(errMessage, e);
    }
}
 
开发者ID:opendatatrentino,项目名称:s-match,代码行数:22,代码来源:MiscUtils.java

示例12: stringToClassInstances

import it.unitn.disi.common.DISIException; //导入依赖的package包/类
/**
 * Parses a string of class names separated by separator into a list of objects.
 *
 * @param str        names of classes
 * @param separator  separator characters
 * @param attrTypes  attrTypes
 * @param attrValues attrValues
 * @return ArrayList of class instances
 * @throws DISIException DISIException
 */
public static List<Object> stringToClassInstances(String str, String separator, Class[] attrTypes,
                                                  Object[] attrValues) throws DISIException {
    ArrayList<Object> tmp = new ArrayList<Object>();
    StringTokenizer stringTokenizer = new StringTokenizer(str, separator);
    while (stringTokenizer.hasMoreTokens()) {
        Object obj = getClassInstance(stringTokenizer.nextToken(), attrTypes, attrValues);
        if (obj != null) {
            tmp.add(obj);
        }
    }
    return tmp;
}
 
开发者ID:opendatatrentino,项目名称:s-match,代码行数:23,代码来源:ClassFactory.java

示例13: readHash

import it.unitn.disi.common.DISIException; //导入依赖的package包/类
/**
 * Loads the hashmap with multiwords. The multiwords are stored in the following format:
 * Key - the first word in the multiwords
 * Value - List of Lists, which contain the other words in the all the multiwords starting with key.
 *
 * @param url hashmap location
 * @return multiwords hashmap
 * @throws SMatchException SMatchException
 */
@SuppressWarnings("unchecked")
private static Map<String, List<List<String>>> readHash(String url) throws SMatchException {
    try {
        return (Map<String, List<List<String>>>) MiscUtils.readObject(url);
    } catch (DISIException e) {
        throw new SMatchException(e.getMessage(), e);
    }
}
 
开发者ID:s-match,项目名称:s-match-wordnet,代码行数:18,代码来源:WordNet.java

示例14: readHash

import it.unitn.disi.common.DISIException; //导入依赖的package包/类
/**
 * Loads the hashmap with multiwords. The multiwords are stored in the following format:
 * Key - the first word in the multiwords
 * Value - List of Lists, which contain the other words in the all the multiwords starting with key.
 *
 * @param fileName the file name from which the hashmap will be read
 * @parm isInternalFile reads from internal data file in resources folder
 * @return multiwords hashmap
 * @throws it.unitn.disi.smatch.SMatchException SMatchException
 */
@SuppressWarnings("unchecked")
private static HashMap<String, ArrayList<ArrayList<String>>> readHash(String fileName, boolean isInternalFile) throws SMatchException {
    try {
        return (HashMap<String, ArrayList<ArrayList<String>>>) MiscUtils.readObject(fileName, isInternalFile);
    } catch (DISIException e) {
        throw new SMatchException(e.getMessage(), e);
    }
}
 
开发者ID:opendatatrentino,项目名称:s-match,代码行数:19,代码来源:WordNet.java


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