Package com.opengamma

Examples of com.opengamma.OpenGammaRuntimeException


    final long predictedSize = producer.getSize(msgInEnv, null, null, null, null);
    final ByteArrayOutputStream bos = new ByteArrayOutputStream();
    try {
      producer.writeTo(msgInEnv, msgInEnv.getClass(), null, null, null, null, bos);
    } catch (IOException e) {
      throw new OpenGammaRuntimeException("ioexception", e);
    }
    final byte[] data = bos.toByteArray();
    if (predictedSize != -1) {
      assertEquals(predictedSize, data.length);
    }
    assertTrue(consumer.isReadable(FudgeMsgEnvelope.class, null, null, null));
    final ByteArrayInputStream bis = new ByteArrayInputStream(data);
    final FudgeMsg msgOut;
    try {
      final FudgeMsgEnvelope env = (FudgeMsgEnvelope) consumer.readFrom(FudgeMsgEnvelope.class, null, null, null, null, bis);
      assertNotNull(env);
      msgOut = env.getMessage();
    } catch (IOException e) {
      throw new OpenGammaRuntimeException("ioexception", e);
    }
    assertNotNull(msgOut);
    assertEquals("bar", msgOut.getFieldValue(String.class, msgOut.getByName("foo")));
    assertEquals((Integer) 42, msgOut.getFieldValue(Integer.class, msgOut.getByName("number")));
  }
View Full Code Here


    if (timestamp < _lastHitTimestamp) { // could happen if the system clock is played with
      reset(timestamp);     
    }
    long secondsSinceLastHit = getSecondsSinceInception(timestamp) - getSecondsSinceInception(_lastHitTimestamp);
    if (secondsSinceLastHit < 0) {
      throw new OpenGammaRuntimeException("Seconds since last hit should never be negative" + secondsSinceLastHit);
    }
   
    if (secondsSinceLastHit >= _secondsOfHistoryToKeep) {
      Arrays.fill(_hitsHistory, _hits);
    } else {
View Full Code Here

  @SuppressWarnings("unchecked")
  public static <T> T getResult(final AsynchronousExecution ex) {
    try {
      return (T) ex.getResult();
    } catch (final InterruptedException e) {
      throw new OpenGammaRuntimeException("interrupted", e);
    }
  }
View Full Code Here

  /* package */ Tenor toFrequency() {
    try {
      final Period period = Period.parse(getName());
      return Tenor.of(period);
    } catch (DateTimeParseException dpe) {
      throw new OpenGammaRuntimeException("Bad value for tenorBean (" + getName() + ")");
    }
  }
View Full Code Here

  }

  /* package */ YieldConvention toYieldConvention() {
    final YieldConvention yieldConvention = YieldConventionFactory.INSTANCE.getYieldConvention(getName());
    if (yieldConvention == null) {
      throw new OpenGammaRuntimeException("Bad value for yieldConventionBean (" + getName() + ")");
    }
    return yieldConvention;
  }
View Full Code Here

   */
  protected String resolveProperty(String value, int lineNum) {
    String variable = findVariable(value);
    while (variable != null) {
      if (_properties.containsKey(variable) == false) {
        throw new OpenGammaRuntimeException("Variable expansion not found: ${" + variable + "}, line " + lineNum);
      }
      value = StringUtils.replaceOnce(value, "${" + variable + "}", _properties.get(variable));
      variable = findVariable(value);
    }
    return value;
View Full Code Here

   */
  protected List<String> readLines(Resource resource) {
    try {
      return IOUtils.readLines(resource.getInputStream(), "UTF8");
    } catch (IOException ex) {
      throw new OpenGammaRuntimeException("Unable to read resource: " + resource, ex);
    }
  }
View Full Code Here

    try {
      doLoad(resource, depth, config);
      overrideProperties(config);
     
    } catch (RuntimeException ex) {
      throw new OpenGammaRuntimeException("Unable to load INI file: " + resource, ex);
    }
  }
View Full Code Here

      }
      if (line.startsWith("[") && line.endsWith("]")) {
        group = line.substring(1, line.length() - 1);
       
      } else if (group == null) {
        throw new OpenGammaRuntimeException("Invalid format, properties must be specified within a [group], line " + lineNum);
       
      } else {
        int equalsPosition = line.indexOf('=');
        if (equalsPosition < 0) {
          throw new OpenGammaRuntimeException("Invalid format, line " + lineNum);
        }
        String key = line.substring(0, equalsPosition).trim();
        String value = line.substring(equalsPosition + 1).trim();
        if (key.length() == 0) {
          throw new IllegalArgumentException("Invalid empty key, line " + lineNum);
View Full Code Here

      include = ResourceUtils.createResource(includeFile);
    } catch (Exception ex) {
      try {
        include = baseResource.createRelative(includeFile);
      } catch (Exception ex2) {
        throw new OpenGammaRuntimeException(ex2.getMessage(), ex2);
      }
    }
   
    // load and merge
    getLogger().logInfo(StringUtils.repeat(" ", depth) + "   Including item: " + ResourceUtils.getLocation(include));
    try {
      doLoad(include, depth + 1, config);
    } catch (RuntimeException ex) {
      throw new OpenGammaRuntimeException("Unable to load INI file: " + include, ex);
    }
  }
View Full Code Here

TOP

Related Classes of com.opengamma.OpenGammaRuntimeException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.