1 package com.dwipal; 2 3 import java.io.*; 4 5 public class DwSnmpMibRecord 6 implements Serializable { 7 public static final int VALUE_TYPE_NONE = 0; 8 public static final int VALUE_TYPE_NULL = 1; 9 public static final int VALUE_TYPE_INTEGER32 = 2; 10 public static final int VALUE_TYPE_UNSIGNED_INTEGER32 = 3; 11 public static final int VALUE_TYPE_OCTET_STRING = 4; 12 public static final int VALUE_TYPE_OID = 5; 13 public static final int VALUE_TYPE_TIMETICKS = 6; 14 public static final int VALUE_TYPE_IP_ADDRESS = 7; 15 16 public static int recNormal = 0; 17 public static int recVariable = -1; 18 public static int recTable = 1; 19 20 public String name = ""; 21 public String parent = ""; 22 public int number = 0; 23 public String description = ""; 24 public String access = ""; 25 public String status = ""; 26 public String syntax = ""; 27 public int recordType = recNormal; 28 public int tableEntry = -1; 29 public String index = ""; 30 31 47 48 DwSnmpMibRecord() { 49 init(); 50 } 51 52 public void init() { 53 name = ""; 54 parent = ""; 55 number = 0; 56 description = ""; 57 access = ""; 58 status = ""; 59 syntax = ""; 60 recordType = recNormal; 61 index = ""; 62 } 63 64 public String getCompleteString() { 65 String returnVal = new String (""); 66 returnVal = returnVal.concat("Name : " + name + "\n"); 67 returnVal = returnVal.concat("Parent : " + parent + "\n"); 68 returnVal = returnVal.concat("Number : " + number + "\n"); 69 returnVal = returnVal.concat("Access : " + access + "\n"); 70 returnVal = returnVal.concat("Syntax : " + syntax + ""); 71 returnVal = returnVal.concat("Status : " + status + "\n"); 72 if (index.equals("") != true) returnVal = returnVal.concat("Index : " + index + "\n"); 73 String desc = ""; 74 int i = 50; 75 while (i < desc.length()) { 76 desc = desc + description.substring(i - 50, i); 77 desc = desc + "\n"; 78 i += 50; 79 } 80 81 desc = desc + description.substring(i - 50); 82 returnVal = returnVal.concat("Description :" + desc + "\n"); 83 returnVal = returnVal.concat("Type :" + recordType + "\n"); 84 85 return returnVal; 86 } 87 88 public boolean isWritable() { 89 if(access.toUpperCase().indexOf("WRITE")!=-1) { 90 return true; 91 } 92 return false; 93 } 94 public String toString() { 95 return name; 96 } 97 98 104 public boolean checkValidValue(String setValue) { 105 return true; 106 } 107 108 public int getSyntaxID() { 109 String strType=syntax.trim().toUpperCase(); 110 if(strType.indexOf("INTEGER")!=-1) 111 return VALUE_TYPE_INTEGER32; 112 else if(strType.indexOf("COUNTER") !=-1) 113 return VALUE_TYPE_UNSIGNED_INTEGER32; 114 else if(strType.indexOf("STRING") !=-1) 115 return VALUE_TYPE_OCTET_STRING; 116 else if(strType.indexOf("OID")!=-1) 117 return VALUE_TYPE_OID; 118 else if(strType.indexOf("TIMETICK") !=-1) 119 return VALUE_TYPE_TIMETICKS; 120 else if(strType.indexOf("IPADDRESS") !=-1) 121 return VALUE_TYPE_IP_ADDRESS; 122 else if(strType.indexOf("NULL") !=-1) 123 return VALUE_TYPE_NULL; 124 125 return VALUE_TYPE_NONE; 127 } 128 129 134 public String getSyntaxIDString() { 135 switch(getSyntaxID()) { 136 case VALUE_TYPE_INTEGER32: 137 return "Integer"; 138 case VALUE_TYPE_UNSIGNED_INTEGER32: 139 return "Unsigned Integer"; 140 case VALUE_TYPE_OCTET_STRING: 141 return "Octet String"; 142 case VALUE_TYPE_OID: 143 return "OID"; 144 case VALUE_TYPE_TIMETICKS: 145 return "Time Ticks"; 146 case VALUE_TYPE_IP_ADDRESS: 147 return "IP Address"; 148 case VALUE_TYPE_NULL: 149 return "Null"; 150 } 151 return "Unknown"; 152 } 153 } 154 155 156 157 | Popular Tags |