/** * Free memory */ public void close() { Hyphen.getLibrary().hnj_hyphen_free(dictionary); }
@Reference( name = "LibhyphenLibrary", unbind = "-", service = NativePath.class, target = "(identifier=http://hunspell.sourceforge.net/Hyphen/native/*)", cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.STATIC ) protected void bindLibrary(NativePath path) { URI libraryPath = path.get("libhyphen").iterator().next(); Hyphen.setLibraryPath(asFile(path.resolve(libraryPath))); logger.debug("Registering libhyphen library: " + libraryPath); }
/** * Default constructor * @param dictPath The path to the hyphenation dictionary file, * e.g. /usr/share/hyphen/hyph_de_DE.dic * @throws FileNotFoundException if the dictionary file cannot be found. * @throws CompilationException if the encoding of the file is not supported. */ public Hyphenator(File dictionaryFile) throws CompilationException, FileNotFoundException { if (!dictionaryFile.exists()) throw new FileNotFoundException("Dictionary file at " + dictionaryFile.getAbsolutePath() + " doesn't exist."); try { charset = getCharset(dictionaryFile); } catch(UnsupportedCharsetException e) { throw new CompilationException(e); } dictionary = Hyphen.getLibrary().hnj_hyphen_load(dictionaryFile.getAbsolutePath()); }
PointerByReference posPointer = new PointerByReference(Pointer.NULL); PointerByReference cutPointer = new PointerByReference(Pointer.NULL); Hyphen.getLibrary().hnj_hyphen_hyphenate2(dictionary, wordBytes, wordSize, wordHyphens, null, repPointer, posPointer, cutPointer); if (repPointer.getValue() != Pointer.NULL)
PointerByReference posPointer = new PointerByReference(Pointer.NULL); PointerByReference cutPointer = new PointerByReference(Pointer.NULL); Hyphen.getLibrary().hnj_hyphen_hyphenate2(dictionary, wordBytes, wordSize, wordHyphens, null, repPointer, posPointer, cutPointer);