@RubyLevelMethod(name = ">") public RubyValue opGt(RubyValue v) { if (v instanceof RubyFixnum) { return ObjectFactory.createBoolean(this.value_ > ((RubyFixnum) v).value_); } else if (v instanceof RubyFloat) { return ObjectFactory.createBoolean(this.value_ > v.toFloat()); } return coerceRelop(RubyID.gtID, v); }
@RubyLevelMethod(name = "===") public static RubyValue objEqual(RubyValue receiver, RubyValue arg) { if (receiver == arg) { return RubyConstant.QTRUE; } else { boolean result = RubyAPI.callPublicOneArgMethod(receiver, arg, null, RubyID.equalID).isTrue(); return ObjectFactory.createBoolean(result); } }
public DataBlockDefinitionType(final DataBlockDefinition db) { if (db != null) { this.id = db.getId(); if (db.getEncoding() != null) { this.encoding = new AbstractEncodingPropertyType(db.getEncoding()); } if (db.getComponents() != null) { final ObjectFactory factory = new ObjectFactory(); this.components = new ArrayList<JAXBElement<? extends AbstractDataComponentType>>(); for (AbstractDataComponent c : db.getComponents()) { if (c instanceof BooleanType) { this.components.add(factory.createBoolean(new BooleanType((BooleanType) c))); } else if (c instanceof ConditionalValueType) { this.components.add( factory.createConditionalValue(new ConditionalValueType((ConditionalValueType) c))); } else if (c instanceof DataArrayType) { this.components.add(factory.createDataArray(new DataArrayType((DataArrayType) c))); } else if (c instanceof DataRecordType) { this.components.add(factory.createDataRecord(new DataRecordType((DataRecordType) c))); } else if (c instanceof EnvelopeType) { this.components.add(factory.createEnvelope(new EnvelopeType((EnvelopeType) c))); } else if (c instanceof GeoLocationArea) { this.components.add( factory.createGeoLocationArea(new GeoLocationArea((GeoLocationArea) c))); } else if (c instanceof PositionType) { this.components.add(factory.createPosition(new PositionType((PositionType) c))); } else if (c instanceof QuantityType) { this.components.add(factory.createQuantity(new QuantityType((QuantityType) c))); } else if (c instanceof SimpleDataRecordType) { this.components.add( factory.createSimpleDataRecord(new SimpleDataRecordType((SimpleDataRecordType) c))); } else if (c instanceof SquareMatrixType) { this.components.add( factory.createSquareMatrix(new SquareMatrixType((SquareMatrixType) c))); } else if (c instanceof TimeType) { this.components.add(factory.createTime(new TimeType((TimeType) c))); } else if (c instanceof VectorType) { this.components.add(factory.createVector(new VectorType((VectorType) c))); } else if (c instanceof AbstractDataRecordType) { this.components.add( factory.createAbstractDataRecord( new AbstractDataRecordType((AbstractDataRecordType) c))); } else if (c instanceof AbstractDataComponentType) { this.components.add( factory.createAbstractDataComponent( new AbstractDataComponentType((AbstractDataComponentType) c))); } else { throw new IllegalArgumentException( "unexpected type for component:" + c.getClass().getName()); } } } } }
@RubyLevelMethod(name = "==") public RubyValue opEqual(RubyValue arg) { if (arg == this) { return RubyConstant.QTRUE; } if (arg instanceof RubyFixnum) { return ObjectFactory.createBoolean(this.value_ == ((RubyFixnum) arg).value_); } return RubyAPI.callOneArgMethod(arg, this, null, RubyID.equalID); }
@RubyLevelMethod(name = "respond_to?") public static RubyValue respond_to(RubyValue receiver, RubyArray args) { if (null == args || args.size() < 1) { int actual_argc = (null == args) ? 0 : args.size(); throw new RubyException( RubyRuntime.ArgumentErrorClass, "in `respond_to': wrong number of arguments (" + actual_argc + " for 1)"); } boolean include_private = (RubyConstant.QTRUE == args.get(1)); RubyID mid = RubyID.intern(args.get(0).toStr()); return ObjectFactory.createBoolean(hasMethod(receiver, mid, include_private)); }
/** * créé un nouveau resultat d'observation. Liste de valeur decrite dans swe:DatablockDefinition de * type simple, pour valeur scalaire ou textuelle. * * @param id l'identifiant du resultat. * @param components liste de composant data record. * @param encoding encodage des données. */ public DataBlockDefinitionType( final String id, final Collection<? extends AbstractDataComponentType> components, final AbstractEncodingType encoding) { this.id = id; this.components = new ArrayList<JAXBElement<? extends AbstractDataComponentType>>(); final ObjectFactory factory = new ObjectFactory(); for (AbstractDataComponent c : components) { if (c instanceof BooleanType) { this.components.add(factory.createBoolean((BooleanType) c)); } else if (c instanceof ConditionalValueType) { this.components.add(factory.createConditionalValue((ConditionalValueType) c)); } else if (c instanceof DataArrayType) { this.components.add(factory.createDataArray((DataArrayType) c)); } else if (c instanceof DataRecordType) { this.components.add(factory.createDataRecord((DataRecordType) c)); } else if (c instanceof EnvelopeType) { this.components.add(factory.createEnvelope((EnvelopeType) c)); } else if (c instanceof GeoLocationArea) { this.components.add(factory.createGeoLocationArea((GeoLocationArea) c)); } else if (c instanceof PositionType) { this.components.add(factory.createPosition((PositionType) c)); } else if (c instanceof QuantityType) { this.components.add(factory.createQuantity((QuantityType) c)); } else if (c instanceof SimpleDataRecordType) { this.components.add(factory.createSimpleDataRecord((SimpleDataRecordType) c)); } else if (c instanceof SquareMatrixType) { this.components.add(factory.createSquareMatrix((SquareMatrixType) c)); } else if (c instanceof TimeType) { this.components.add(factory.createTime((TimeType) c)); } else if (c instanceof VectorType) { this.components.add(factory.createVector((VectorType) c)); } else if (c instanceof AbstractDataArrayType) { this.components.add(factory.createAbstractDataArray((AbstractDataArrayType) c)); } else if (c instanceof AbstractDataRecordType) { this.components.add(factory.createAbstractDataRecord((AbstractDataRecordType) c)); } else if (c instanceof AbstractDataComponentType) { this.components.add(factory.createAbstractDataComponent((AbstractDataComponentType) c)); } else { throw new IllegalArgumentException( "unexpected type for component:" + c.getClass().getName()); } } this.encoding = new AbstractEncodingPropertyType(encoding); }
// @RubyLevelMethod(name="==") public RubyValue opEqual(RubyValue v) { if (this == v) { return RubyConstant.QTRUE; } if (v instanceof RubyString) { RubyString str = ((RubyString) v); if ((this.sb_.length() == str.sb_.length() && this.cmp(str) == 0)) { return RubyConstant.QTRUE; } else { return RubyConstant.QFALSE; } } if (v.respondTo(RubyID.toStrID)) { return ObjectFactory.createBoolean(v.equals(this)); } else { return RubyConstant.QFALSE; } }
// @RubyLevelMethod(name="eql?") public RubyValue opEql(RubyValue v) { return ObjectFactory.createBoolean(equals(v, false)); }
// @RubyLevelMethod(name="empty?") public RubyValue empty_p() { return ObjectFactory.createBoolean(this.array_.isEmpty()); }
@RubyLevelMethod(name = "tainted?") public static RubyValue tainted(RubyValue receiver) { return ObjectFactory.createBoolean(receiver.tainted()); }
@RubyLevelMethod(name = "frozen?") public static RubyValue frozen(RubyValue receiver) { return ObjectFactory.createBoolean(receiver.frozen()); }
@RubyLevelMethod(name = "block_given?", alias = "iterator?", module = true) public static RubyValue blockGivenP(RubyValue receiver, RubyBlock block) { return ObjectFactory.createBoolean(null != block); }
@RubyLevelMethod( name = "==", alias = {"equal?", "eql?"}) public static RubyValue opEqual(RubyValue receiver, RubyValue arg) { return ObjectFactory.createBoolean(receiver == arg); }
@RubyLevelMethod(name = "instance_of?") public static RubyValue instanceOf(RubyValue receiver, RubyValue arg) { return ObjectFactory.createBoolean(receiver.getRubyClass().getRealClass() == arg); }
@RubyLevelMethod(name = "kind_of?", alias = "is_a?") public static RubyValue kindOf(RubyValue receiver, RubyValue arg) { return ObjectFactory.createBoolean(RubyAPI.isKindOf(arg, receiver)); }
// RHO_MOBILE // @RubyLevelMethod(name = "include?") public RubyValue include_p(RubyValue arg) { int nIndex = sb_.toString().indexOf(arg.toStr()); return ObjectFactory.createBoolean(nIndex >= 0); }