📄 qosdata.java
字号:
RouteInfo ri = (RouteInfo)routeNodeList.get(ii); if (ri.getNodeId().equals(nodeId)) { return ri.getDirtyRead(); } } return false; } /** * The data size for persistence * @return The size in bytes of the data in XML form */ public int size() { return toXml().length(); } /** The literal XML string of the QoS */ public abstract String toXml(); /** * Dump state of this object into a XML ASCII string. * <br> * @param extraOffset indenting of tags for nice output * @param forceReadable hint to dump in human readable form (avoid Base64) * @return internal state of the query as a XML ASCII string * */ public abstract String toXml(String extraOffset, Properties props); /* public String toXml(String extraOffset, Properties props) { // Derived classes may implement it return toXml(); }*/ public final Global getGlobal() { return this.glob; } public final MethodName getMethod() { return this.methodName; } public final void setMethod(MethodName methodName) { this.methodName = methodName; } public final boolean isPublish() { return this.methodName == MethodName.PUBLISH; } public final boolean isSubscribe() { return this.methodName == MethodName.SUBSCRIBE; } public final boolean isUnSubscribe() { return this.methodName == MethodName.UNSUBSCRIBE; } public final boolean isErase() { return this.methodName == MethodName.ERASE; } public final boolean isGet() { return this.methodName == MethodName.GET; } public final boolean isUpdate() { return this.methodName == MethodName.UPDATE; } /** * Returns a deep clone, you can change savely all mutable types. * Immutable types are not cloned as they can't be changed. */ public Object clone() { QosData newOne = null; try { newOne = (QosData)super.clone(); synchronized(this) { //Timestamp is immutable, no clone necessary //newOne.rcvTimestamp = (Timestamp)this.rcvTimestamp.clone(); newOne.persistent = (PropBoolean)this.persistent.clone(); //SessionName is immutable, no clone necessary //if (this.sender != null) { // newOne.sender = (SessionName)this.sender.clone(); //} if (this.routeNodeList != null/* && this.routeNodeList.size() > 0*/) { newOne.routeNodeList = (ArrayList)this.routeNodeList.clone(); } if (this.clientProperties != null/* && this.clientProperties.size() > 0*/) { newOne.clientProperties = (HashMap)((HashMap)this.clientProperties).clone(); } } } catch (CloneNotSupportedException e) { e.printStackTrace(); } return newOne; } /** * Sets the client property to the given value */ public final void addClientProperty(ClientProperty clientProperty) { this.clientProperties.put(clientProperty.getName(), clientProperty); } /** * Sets the client property to the given value * @param key * @param type For example Constants.TYPE_FLOAT * @param value Of any type, it will be forced to the given <code>type</code> */ public final void addClientProperty(String key, String type, Object value) { String encoding = null; String str = (value == null) ? null : value.toString(); ClientProperty clientProperty = new ClientProperty(key, type, encoding, str); this.clientProperties.put(clientProperty.getName(), clientProperty); } /** * Sets the client property to the given value * @param key * @param value for example a Float or Integer value */ public final void addClientProperty(String key, Object value) { addClientProperty(key, ClientProperty.getPropertyType(value), value); } /** * Sets the client property to the given value * @param key * @param value */ public final void addClientProperty(String key, boolean value) { addClientProperty(key, Constants.TYPE_BOOLEAN, ""+value); } /** * Sets the client property to the given value * @param key * @param value */ public final void addClientProperty(String key, int value) { addClientProperty(key, Constants.TYPE_INT, ""+value); } /** * Sets the client property to the given value * @param key * @param value */ public final void addClientProperty(String key, byte value) { addClientProperty(key, Constants.TYPE_BYTE, ""+value); } /** * Sets the client property to the given value * @param key * @param value */ public final void addClientProperty(String key, long value) { addClientProperty(key, Constants.TYPE_LONG, ""+value); } /** * Sets the client property to the given value * @param key * @param value */ public final void addClientProperty(String key, short value) { addClientProperty(key, Constants.TYPE_SHORT, ""+value); } /** * Sets the client property to the given value * @param key * @param value */ public final void addClientProperty(String key, double value) { addClientProperty(key, Constants.TYPE_DOUBLE, ""+value); } /** * Sets the client property to the given value * @param key * @param value */ public final void addClientProperty(String key, float value) { addClientProperty(key, Constants.TYPE_FLOAT, ""+value); } /** * Access the client property. * @param name The property key * @return The ClientProperty instance or null if not found */ public final ClientProperty getClientProperty(String name) { if (name == null) return null; return (ClientProperty)this.clientProperties.get(name); } /** * Check for client property. * @param name The property key * @return true if the property exists */ public final boolean propertyExists(String name) { if (name == null) return false; return (this.clientProperties.get(name) != null); } /** * Access the String client property. * @param name The property key * @param defaultValue The value to return if the property is not known */ public final String getClientProperty(String name, String defaultValue) { if (name == null) return defaultValue; ClientProperty p = (ClientProperty)this.clientProperties.get(name); if (p == null) return defaultValue; return p.getStringValue(); } /** * Access the integer client property. * @param name The property key * @param defaultValue The value to return if the property is not known */ public final int getClientProperty(String name, int defaultValue) { if (name == null) return defaultValue; ClientProperty p = (ClientProperty)this.clientProperties.get(name); if (p == null) return defaultValue; return p.getIntValue(); } /** * Access the boolean client property. * @param name The property key * @param defaultValue The value to return if the property is not known */ public final boolean getClientProperty(String name, boolean defaultValue) { if (name == null) return defaultValue; ClientProperty p = (ClientProperty)this.clientProperties.get(name); if (p == null) return defaultValue; return p.getBooleanValue(); } /** * Access the double client property. * @param name The property key * @param defaultValue The value to return if the property is not known */ public final double getClientProperty(String name, double defaultValue) { if (name == null) return defaultValue; ClientProperty p = (ClientProperty)this.clientProperties.get(name); if (p == null) return defaultValue; return p.getDoubleValue(); } /** * Access the float client property. * @param name The property key * @param defaultValue The value to return if the property is not known */ public final float getClientProperty(String name, float defaultValue) { if (name == null) return defaultValue; ClientProperty p = (ClientProperty)this.clientProperties.get(name); if (p == null) return defaultValue; return p.getFloatValue(); } /** * Access the byte client property. * @param name The property key * @param defaultValue The value to return if the property is not known */ public final byte getClientProperty(String name, byte defaultValue) { if (name == null) return defaultValue; ClientProperty p = (ClientProperty)this.clientProperties.get(name); if (p == null) return defaultValue; return p.getByteValue(); } /** * Access the byte[] client property. * @param name The property key * @param defaultValue The value to return if the property is not known */ public final byte[] getClientProperty(String name, byte[] defaultValue) { if (name == null) return defaultValue; ClientProperty p = (ClientProperty)this.clientProperties.get(name); if (p == null) return defaultValue; return p.getBlobValue(); } /** * Access the long client property. * @param name The property key * @param defaultValue The value to return if the property is not known */ public final long getClientProperty(String name, long defaultValue) { if (name == null) return defaultValue; ClientProperty p = (ClientProperty)this.clientProperties.get(name); if (p == null) return defaultValue; return p.getLongValue(); } /** * Access the short client property. * @param name The property key * @param defaultValue The value to return if the property is not known */ public final short getClientProperty(String name, short defaultValue) { if (name == null) return defaultValue; ClientProperty p = (ClientProperty)this.clientProperties.get(name); if (p == null) return defaultValue; return p.getShortValue(); } /** * Access all client properties. * @return a map The return is unordered and the map values are of type ClientProperty. * @see org.xmlBlaster.util.qos.ClientProperty */ public final Map getClientProperties() { return this.clientProperties; } public final String writePropertiesXml(String offset) { return writePropertiesXml(offset, false); } public final String writePropertiesXml(String offset, boolean forceReadable) { if (this.clientProperties.size() > 0) { Object[] arr = this.clientProperties.keySet().toArray(); StringBuffer sb = new StringBuffer(arr.length*256); for (int i=0; i < arr.length; i++) { ClientProperty p = (ClientProperty)this.clientProperties.get(arr[i]); sb.append(p.toXml(offset, null, forceReadable)); } return sb.toString(); } return ""; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -