1 package user.commons.nexio.server.protocol;
3 import java.io.IOException;
4 import java.util.Calendar;
6 public class NexioServerProtocolImpl implements NexioServerProtocol {
8 private GetExtendedIDFromIDHandleCommand getExtendedIDFromIDHandleCommand = null;
9 private GetIDMetadataCommand getIDMetadataCommand = null;
10 private GetIDHandleFromExtendedIDCommand getIDHandleFromExtendedIDCommand = null;
11 private GetExtendedFieldGetModifiedTimestampCommand getExtendedFieldGetModifiedTimestampCommand = null;
12 private GetExtendedFieldGetRecordDateTimestampCommand getExtendedFieldGetRecordDateTimestampCommand = null;
13 private ListFirstIDHandleCommand listFirstIDHandleCommand = null;
14 private ListNextIDHandleCommand listNextIDHandleCommand = null;
15 private GetIDFileSizeCommand getIDFileSizeCommand = null;
16 private PortStatusCommand portStatusCommand = null;
17 private GetExtendedFieldCommand getExtendedFieldCommand = null;
19 private Connection connection = null;
21 public NexioServerProtocolImpl(Connection _connection) {
22 this.connection = _connection;
23 getExtendedIDFromIDHandleCommand = new GetExtendedIDFromIDHandleCommand(connection);
24 getIDMetadataCommand = new GetIDMetadataCommand(connection);
25 getIDHandleFromExtendedIDCommand = new GetIDHandleFromExtendedIDCommand(connection);
26 getExtendedFieldGetModifiedTimestampCommand = new GetExtendedFieldGetModifiedTimestampCommand(connection);
27 getExtendedFieldGetRecordDateTimestampCommand = new GetExtendedFieldGetRecordDateTimestampCommand(connection);
28 listFirstIDHandleCommand = new ListFirstIDHandleCommand(connection);
29 listNextIDHandleCommand = new ListNextIDHandleCommand(connection);
30 getIDFileSizeCommand = new GetIDFileSizeCommand(connection);
31 portStatusCommand = new PortStatusCommand(connection);
32 getExtendedFieldCommand = new GetExtendedFieldCommand(connection);
36 public byte[] executeGetExtendedFieldCommand(Id id, byte[] fieldNumber) throws IOException, ProtocolException {
37 return getExtendedFieldCommand.execute(id, fieldNumber);
41 public Calendar executeGetExtendedFieldGetModifiedTimestamp(Id id) throws IOException, ProtocolException {
42 return getExtendedFieldGetModifiedTimestampCommand.execute(id);
46 public Calendar executeGetExtendedFieldGetRecordDateTimestamp(Id id) throws IOException, ProtocolException {
47 return getExtendedFieldGetRecordDateTimestampCommand.execute(id);
51 public Xid executeGetExtendedIDFromIDHandle(Id id) throws IOException, ProtocolException {
52 return getExtendedIDFromIDHandleCommand.execute(id);
56 public long executeGetIDFileSizeCommand(Id id) throws IOException, ProtocolException {
57 return getIDFileSizeCommand.execute(id);
61 public Id executeGetIDHandleFromExtendedID(Xid xid) throws IOException, ProtocolException {
62 return getIDHandleFromExtendedIDCommand.execute(xid);
66 public byte[] executeGetIDMetadata(Id id) throws IOException, ProtocolException {
67 return getIDMetadataCommand.execute(id);
71 public Id executeListFirstIDHandle() throws IOException, ProtocolException {
72 return listFirstIDHandleCommand.execute();
76 public Id executeListNextIDHandle() throws IOException, ProtocolException {
77 return listNextIDHandleCommand.execute();
81 public byte executePortStatusCommand() throws IOException, ProtocolException {
82 return portStatusCommand.execute();
86 public Connection getConnection() {
87 return this.connection;
91 public void setDescription(String id, String description) throws IOException {
92 byte[] SET_DESCRIPTION = ("...." + id + description).getBytes();
93 SET_DESCRIPTION[0] = (byte) 0xCF;
94 SET_DESCRIPTION[1] = (byte) 0xCC;
95 SET_DESCRIPTION[2] = (byte) 0xBC;
96 SET_DESCRIPTION[3] = (byte) 0x12;
97 connection.write(SET_DESCRIPTION);