@Override protected int getMarshalingCostImpl(Value argValue) { if (argValue instanceof LongValue) return Marshal.ONE; else if (argValue.isLongConvertible()) return LONG_CONVERTIBLE_INTEGER_OBJECT_COST; else if (argValue.isDoubleConvertible()) return DOUBLE_CONVERTIBLE_INTEGER_OBJECT_COST; else return Marshal.FOUR; }
/** Implementation for getting the indices of this class. i.e. <code>$a->foo[0]</code> */ public Value __get(Env env, Value indexV) { if (indexV.isString()) { String name = indexV.toString(); SimpleXMLElement attr = getAttribute(name); if (attr == null) return NullValue.NULL; else return wrapJava(env, _cls, attr); } else if (indexV.isLongConvertible()) { int i = indexV.toInt(); if (i == 0) return wrapJava(env, _cls, getOwner()); else if (_parent == null) return NullValue.NULL; ArrayList<SimpleXMLElement> children = _parent._children; if (children != null) { int size = children.size(); for (int j = 0; j < size; j++) { SimpleXMLElement child = children.get(j); if (child.getName().equals(getName()) && i-- == 0) return wrapJava(env, _cls, child); } } return NullValue.NULL; } else return NullValue.NULL; }
@Override protected int getMarshalingCostImpl(Value argValue) { if (argValue instanceof JavaDateValue) return Marshal.ZERO; else if (argValue instanceof LongValue) return Marshal.THREE; else if (argValue.isLongConvertible()) return Marshal.THREE; else return Marshal.FOUR; }
public boolean send(@NotNull Value value, @Optional JMSQueue replyTo) throws JMSException { Message message = null; if (value.isArray()) { message = _session.createMapMessage(); ArrayValue array = (ArrayValue) value; Set<Map.Entry<Value, Value>> entrySet = array.entrySet(); for (Map.Entry<Value, Value> entry : entrySet) { if (entry.getValue() instanceof BinaryValue) { byte[] bytes = ((BinaryValue) entry.getValue()).toBytes(); ((MapMessage) message).setBytes(entry.getKey().toString(), bytes); } else { // every primitive except for bytes can be translated from a string ((MapMessage) message).setString(entry.getKey().toString(), entry.getValue().toString()); } } } else if (value instanceof BinaryValue) { message = _session.createBytesMessage(); byte[] bytes = ((BinaryValue) value).toBytes(); ((BytesMessage) message).writeBytes(bytes); } else if (value.isLongConvertible()) { message = _session.createStreamMessage(); ((StreamMessage) message).writeLong(value.toLong()); } else if (value.isDoubleConvertible()) { message = _session.createStreamMessage(); ((StreamMessage) message).writeDouble(value.toDouble()); } else if (value.toJavaObject() instanceof String) { message = _session.createTextMessage(); ((TextMessage) message).setText(value.toString()); } else if (value.toJavaObject() instanceof Serializable) { message = _session.createObjectMessage(); ((ObjectMessage) message).setObject((Serializable) value.toJavaObject()); } else { return false; } if (replyTo != null) message.setJMSReplyTo(replyTo._destination); _producer.send(message); return true; }
/** Implementation for getting the indices of this class. i.e. <code>$a->foo[0]</code> */ public Value __get(Env env, Value indexV) { if (indexV.isString()) { String name = indexV.toString(); SimpleXMLElement attr = getAttribute(name); if (attr != null) return wrapJava(env, _cls, attr); else return NullValue.NULL; } else if (indexV.isLongConvertible()) { int i = indexV.toInt(); if (i < _attributes.size()) return wrapJava(env, _cls, _attributes.get(i)); return NullValue.NULL; } else return NullValue.NULL; }