PageRenderTime 11ms CodeModel.GetById 2ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/ictclas4j/src/org/ictclas4j/bean/Pos.java

http://ictclas4j.googlecode.com/
Java | 96 lines | 69 code | 20 blank | 7 comment | 4 complexity | f73c3fe8a061211d36c4ad4e0e08882a MD5 | raw file
 1package org.ictclas4j.bean;
 2
 3import java.io.DataInputStream;
 4import java.io.DataOutputStream;
 5import java.io.IOException;
 6import java.io.Serializable;
 7
 8/**
 9 * ??
10 * 
11 * @author sinboy
12 * @since 2008.6.4
13 * 
14 */
15public class Pos implements Cloneable, Serializable {
16	private int tag;// ????4?????????????????ASCII??????POSTag
17
18	private int freq;// ??
19
20	private boolean isVisible;// ??????????????????????
21
22	private static final long serialVersionUID = 10000L;
23
24	public Pos() {
25
26	}
27
28	public Pos(int tag, int freq, boolean isVisible) {
29		this.tag = tag;
30		this.freq = freq;
31		this.isVisible = isVisible;
32	}
33
34	public int read(DataInputStream in) throws IOException {
35		int offset = 0;
36		if (in != null) {
37			tag = in.readInt();
38			freq = in.readInt();
39			offset += 8;
40		}
41		return offset;
42	}
43
44	public int write(DataOutputStream out) throws IOException {
45		int offset = 0;
46		if (out != null) {
47			out.writeInt(tag);
48			out.writeInt(freq);
49			offset += 8;
50		}
51		return offset;
52	}
53
54	public int getTag() {
55		return tag;
56	}
57
58	public void setTag(int tag) {
59		this.tag = tag;
60	}
61
62	public int getFreq() {
63		return freq;
64	}
65
66	public void setFreq(int freq) {
67		this.freq = freq;
68	}
69
70	public boolean isVisible() {
71		return isVisible;
72	}
73
74	public void setVisible(boolean isVisible) {
75		this.isVisible = isVisible;
76	}
77
78	public String toString() {
79		StringBuffer sb = new StringBuffer();
80		sb.append(POSTag.int2str(tag)); 
81		return sb.toString();
82	}
83	
84	public String toString2() {
85		StringBuffer sb = new StringBuffer();
86		sb.append(POSTag.int2str(tag));
87		sb.append(",").append(freq);
88		sb.append(",").append(isVisible ? 1 : 0);
89		return sb.toString();
90	}
91
92
93	public Pos clone() throws CloneNotSupportedException {
94		return (Pos) super.clone();
95	}
96}