/** * Constructs a new sense entry object. * * @param key * the sense key of the entry * @param offset * the synset offset of the entry * @param num * the sense number of the entry * @param count * the tag count of the entry * @since JWI 2.1.0 */ public SenseEntry(ISenseKey key, int offset, int num, int count){ if(key == null) throw new NullPointerException(); Synset.checkOffset(offset); this.key = key; this.offset = offset; this.num = num; this.count = count; }
/** * Constructs a new synset id with the specified offset and part of speech. * * @param offset * the offset * @param pos * the part of speech; may not be <code>null</code> * @throws NullPointerException * if the specified part of speech is <code>null</code> * @throws IllegalArgumentException * if the specified offset is not a legal offset * @since JWI 1.0 */ public SynsetID(int offset, POS pos) { if (pos == null) throw new NullPointerException(); Synset.checkOffset(offset); this.offset = offset; this.pos = pos; }
/** * Takes an integer in the closed range [0,99999999] and converts it into an * eight decimal digit zero-filled string. E.g., "1" becomes "00000001", * "1234" becomes "00001234", and so on. This is used for the generation of * synset and word numbers. * * @param offset * the offset to be converted * @return the zero-filled string representation of the offset * @throws IllegalArgumentException * if the specified offset is not in the valid range of * [0,99999999] * @since JWI 2.1.0 */ public static String zeroFillOffset(int offset){ checkOffset(offset); StringBuilder sb = new StringBuilder(8); String offsetStr = Integer.toString(offset); int numZeros = 8-offsetStr.length(); for(int i = 0; i < numZeros; i++) sb.append('0'); sb.append(offsetStr); return sb.toString(); }