コード例 #1
0
ファイル: Regexp.java プロジェクト: igorhvr/bedlam
    public Value matchPositions(Value str) {
      PatternMatcher matcher = getMatcher();

      // Do the matching
      PatternMatcherInput jStr = new PatternMatcherInput(string(str));
      Pair result = null;
      Pair prev = null;
      boolean found = false;

      while (matcher.contains(jStr, pattern)) {
        found = true;

        MatchResult matchResult = matcher.getMatch();

        for (int i = 0, length = matchResult.groups(); i < length; i++) {
          Pair m =
              new Pair(
                  Quantity.valueOf(matchResult.beginOffset(i)),
                  Quantity.valueOf(matchResult.endOffset(i)));
          Pair elem = new Pair(m, EMPTYLIST);
          if (result == null) result = prev = elem;
          else {
            prev.setCdr(elem);
            prev = elem;
          }
        }
      }

      if (!found) return FALSE;
      else return result;
    }
コード例 #2
0
ファイル: Specimen.java プロジェクト: jmandel/fhir-lib
 public SpecimenContainerComponent copy(Specimen e) {
   SpecimenContainerComponent dst = e.new SpecimenContainerComponent();
   dst.identifier = new ArrayList<Identifier>();
   for (Identifier i : identifier) dst.identifier.add(i.copy());
   dst.description = description == null ? null : description.copy();
   dst.type = type == null ? null : type.copy();
   dst.capacity = capacity == null ? null : capacity.copy();
   dst.specimenQuantity = specimenQuantity == null ? null : specimenQuantity.copy();
   dst.additive = additive == null ? null : additive.copy();
   return dst;
 }
コード例 #3
0
ファイル: TestWeirdTypes.java プロジェクト: lobonala/jenabean
 @Test
 public void testDouble() {
   Model m = ModelFactory.createDefaultModel();
   Bean2RDF writer = new Bean2RDF(m);
   RDF2Bean reader = new RDF2Bean(m);
   Quantity q = new Quantity();
   q.setAmount(1.0002);
   q.setUnits("km");
   writer.save(q);
   Quantity q2 = reader.load(Quantity.class, 1.0002);
   assertNotNull(q2);
 }
コード例 #4
0
 protected PersistentQuantity doInvertSign(final PersistentQuantity q)
     throws PersistenceException {
   final Fraction amount = FractionManager.getTheFractionManager().invertSign(q.getAmount());
   final PersistentQuantity res = Quantity.createQuantity(amount, q.getUnit());
   getThis().getQuantities().add(res);
   return res;
 }
コード例 #5
0
  @Override
  public PersistentQuantity createQuantity(
      final PersistentAbsUnit unit, final common.Fraction amount) throws PersistenceException {
    // amount in FractionManager suchen oder neu erstellen.
    final String fractionStroke = "/";
    final String enumeratorString = amount.getEnumerator().toString();
    final String denominatorString = amount.getEnumerator().toString();
    final String fractionSearchString = enumeratorString + fractionStroke + denominatorString;
    common.Fraction persistentAmount;

    try {
      persistentAmount = FractionManager.getTheFractionManager().getFraction(fractionSearchString);

    } catch (final NotFoundException e) {
      persistentAmount = amount;
      try {
        FractionManager.getTheFractionManager().addFraction(fractionSearchString, persistentAmount);
      } catch (final DoubleDefinitionException e1) {
        System.out.println("error while fraction creation");
      }
    }

    final PersistentQuantity newQuantity = Quantity.createQuantity(amount, unit);
    getThis().getQuantities().add(newQuantity);
    return newQuantity;
  }
コード例 #6
0
ファイル: Specimen.java プロジェクト: jmandel/fhir-lib
 public SpecimenCollectionComponent copy(Specimen e) {
   SpecimenCollectionComponent dst = e.new SpecimenCollectionComponent();
   dst.collector = collector == null ? null : collector.copy();
   dst.comment = new ArrayList<String_>();
   for (String_ i : comment) dst.comment.add(i.copy());
   dst.collectedTime = collectedTime == null ? null : collectedTime.copy();
   dst.quantity = quantity == null ? null : quantity.copy();
   dst.method = method == null ? null : method.copy();
   dst.sourceSite = sourceSite == null ? null : sourceSite.copy();
   return dst;
 }
コード例 #7
0
ファイル: FileManipulation.java プロジェクト: amoe/sisc
 public Value apply(Value v1) throws ContinuationException {
   switch (id) {
     case DIRECTORYQ:
       return SchemeBoolean.get(fileHandle(v1).isDirectory());
     case FILEQ:
       return SchemeBoolean.get(fileHandle(v1).isFile());
     case HIDDENQ:
       return SchemeBoolean.get(fileHandle(v1).isHidden());
     case READABLE:
       return SchemeBoolean.get(fileHandle(v1).canRead());
     case WRITEABLE:
       return SchemeBoolean.get(fileHandle(v1).canWrite());
     case DIRLIST:
       Pair p = EMPTYLIST;
       String[] contents = fileHandle(v1).list();
       if (contents == null)
         throwPrimException(liMessage(IO.IOB, "nosuchdirectory", SchemeString.asString(v1)));
       for (int i = contents.length - 1; i >= 0; i--)
         p = new Pair(new SchemeString(contents[i]), p);
       return p;
     case LENGTH:
       return Quantity.valueOf(fileHandle(v1).length());
     case LASTMODIFIED:
       return Quantity.valueOf(fileHandle(v1).lastModified());
     case GETPARENTURL:
       try {
         return new SchemeString(fileHandle(v1).getParentFile().toURI().toURL().toString());
       } catch (MalformedURLException m) {
         m.printStackTrace();
       }
       break;
     default:
       throwArgSizeException();
   }
   return VOID;
 }
コード例 #8
0
ファイル: Base.java プロジェクト: hl7-fhir/fhir-svn
 public SimpleQuantity castToSimpleQuantity(Base b) throws FHIRException {
   if (b instanceof SimpleQuantity) return (SimpleQuantity) b;
   else if (b instanceof Quantity) {
     Quantity q = (Quantity) b;
     SimpleQuantity sq = new SimpleQuantity();
     sq.setValueElement(q.getValueElement());
     sq.setComparatorElement(q.getComparatorElement());
     sq.setUnitElement(q.getUnitElement());
     sq.setSystemElement(q.getSystemElement());
     sq.setCodeElement(q.getCodeElement());
     return sq;
   } else
     throw new FHIRException(
         "Unable to convert a " + b.getClass().getName() + " to an SimpleQuantity");
 }
コード例 #9
0
 public boolean eq(final Quantity quantity) {
   checkUnitCompatibility(quantity);
   return Quantity.this.getValue() == quantity.getValue();
 }