private POSKey(POS pos, Object key) { if (pos == null || key == null) { throw new JWNLRuntimeException("DICTIONARY_EXCEPTION_001"); } _pos = pos; _key = key; }
private static void checkInitialized(int requiredStage) { if (requiredStage > _initStage) { throw new JWNLRuntimeException("JWNL_EXCEPTION_007"); } }
private static void checkFileType(Class c) { if (!ObjectDictionaryFile.class.isAssignableFrom(c)) { throw new JWNLRuntimeException("DICTIONARY_EXCEPTION_010", c); } }
private void checkFileType(Class c) { if (!DictionaryFile.class.isAssignableFrom(c)) { throw new JWNLRuntimeException("DICTIONARY_EXCEPTION_003", c); } }
/** * Create a new Type checking list that checks for type <var>type</var>, but only if <var>parentType</var> is * equal to, a super class/interface of, or an interface implemented by <var>type</var>. */ protected TypeCheckingList(List backingList, Class type, Class parentType) { if (!parentType.isAssignableFrom(type)) { throw new JWNLRuntimeException("UTILS_EXCEPTION_001", new Object[] { type, parentType }); } init(backingList, type); }
public DictionaryCatalog(String path, DictionaryFileType fileType, Class dictionaryFileType) { _fileType = fileType; try { Constructor c = dictionaryFileType.getConstructor(new Class[0]); DictionaryFile factory = (DictionaryFile) c.newInstance(null); for (Iterator itr = POS.getAllPOS().iterator(); itr.hasNext();) { DictionaryFile file = factory.newInstance(path, (POS)itr.next(), fileType); _files.put(file.getPOS(), file); } } catch (Exception ex) { throw new JWNLRuntimeException("DICTIONARY_EXCEPTION_0018", new Object[]{fileType, dictionaryFileType}, ex); } }
private void typecheck(Object obj) { if (!getType().isInstance(obj)) { throw new JWNLRuntimeException("UTILS_EXCEPTION_003", getType()); } }
public NodeListIteratorWrapper(TypeCheckingList.TypeCheckingListIterator itr) { if (!Node.class.isAssignableFrom(itr.getType())) { throw new JWNLRuntimeException("DATA_EXCEPTION_003", new Object[] { Node.class, itr.getType() }); } _itr = itr; }
private DictionaryCacheSet getCaches() { if (!isCachingEnabled()) { throw new JWNLRuntimeException("DICTIONARY_EXCEPTION_022"); } if (_caches == null) { _caches = new DictionaryCacheSet(); } return _caches; }
public String getCurrentForm() { if (!isCurrentFormAvailable()) { throw new JWNLRuntimeException("DICTIONARY_EXCEPTION_012"); } return getForm(_index); }
public ResultSet execute() throws SQLException { if (isExecuted()) { throw new JWNLRuntimeException("DICTIONARY_EXCEPTION_025"); } return (_results = (getStatement().execute()) ? getStatement().getResultSet() : null); }
public String getNextForm() { if (!isMoreFormsAvailable()) { throw new JWNLRuntimeException("DICTIONARY_EXCEPTION_013"); } return getForm(++_index); }
public String readLine() throws IOException { if (isOpen()) { return _file.readLine(); } else { throw new JWNLRuntimeException("PRINCETON_EXCEPTION_001"); } }
public boolean executeNextOperation() throws JWNLException { if (!isNextOperationAvailable()) { throw new JWNLRuntimeException("DICTIONARY_EXCEPTION_027"); } Operation oper = _operations[++_currentOperation]; return oper.execute(_pos, _derivation, _baseForms); }
public Object readObject() throws IOException, ClassNotFoundException { if (isOpen() && canRead()) { return getInputStream().readObject(); } else { throw new JWNLRuntimeException("PRINCETON_EXCEPTION_001"); } }
public void writeObject(Object obj) throws IOException { if (isOpen() && canWrite()) { getOutputStream().writeObject(obj); } else { throw new JWNLRuntimeException("PRINCETON_EXCEPTION_002"); } }
public Object create(Map params) throws JWNLException { Class fileClass = null; try { fileClass = Class.forName(((Param)params.get(FILE_TYPE)).getValue()); } catch (ClassNotFoundException ex) { throw new JWNLRuntimeException("DICTIONARY_EXCEPTION_002", ex); } checkFileType(fileClass); String path = ((Param)params.get(PATH)).getValue(); try { return new FileManagerImpl(path, fileClass); } catch (IOException ex) { throw new JWNLException("DICTIONARY_EXCEPTION_016", fileClass, ex); } }
public String readLine() throws IOException { if (isOpen()) { //The following lines gratuitously lifted from java.io.RandomAccessFile.readLine() StringBuffer input = new StringBuffer(); char c = (char)-1; boolean eol = false; while (!eol) { c = _buffer.get((int)getFilePointer()); _buffer.position((int)getFilePointer() + 1); switch (c) { case (char)-1: case '\n': eol = true; break; case '\r': eol = true; if ((_buffer.get((int)getFilePointer() + 1)) == '\n') _buffer.position((int)getFilePointer() + 1); break; default: input.append(c); break; } } return ((c == -1) && (input.length() == 0)) ? null : input.toString(); } else { throw new JWNLRuntimeException("PRINCETON_EXCEPTION_001"); } }