Package gov.nist.scap.xccdf.document

Examples of gov.nist.scap.xccdf.document.LiteralValue


    // The schema requires that at least one value be provided
    if (cursor.toFirstChild()) {
      boolean found = false;
      // Build a map of elements using the selector as the key
      do {
        LiteralValue literal;
        XmlObject obj = cursor.getObject();
        if (obj instanceof SelStringType) {
          SelStringType node = (SelStringType)obj;
          literal = new DefaultLiteralValue(
              node.getSelector(),
              Collections.singletonList(node.getStringValue()),
              false);
          found = true;
        } else if (obj instanceof SelComplexValueType) {
          SelComplexValueType node = (SelComplexValueType)obj;
          literal = new DefaultLiteralValue(
              node.getSelector(),
              node.getItemList(),
              true);
          found = true;
        } else {
          if (!found) {
            continue;
          }
          // Not a valid (literal) value instance
          break;
        }
        addLiteralValue(literal);
      } while (cursor.toNextSibling());

      // Check if there is a null selector entry which will correspond to
      // the default entry.  If not present, elect the first entry to be
      // the default with a null selector.
      Map<String, LiteralValue> selectorToLiteralValueMap = getSelectorToLiteralValueMap();
      if (!selectorToLiteralValueMap.containsKey(null)) {
        LiteralValue firstLiteral = selectorToLiteralValueMap.values().iterator().next();
        LiteralValue defaultLiteral = new DefaultLiteralValue(null, firstLiteral.getValues(), firstLiteral.isComplex());
        addLiteralValue(defaultLiteral);
      }
    } else {
      throw new IllegalStateException(new PropertyNotFoundException("value '" + getId()
          + "'is missing a default value property"));
View Full Code Here


    // The schema requires that at least one value be provided
    if (cursor.toFirstChild()) {
      boolean found = false;
      // Build a map of elements using the selector as the key
      do {
        LiteralValue literal;
        XmlObject obj = cursor.getObject();
        if (obj instanceof SelStringType) {
          SelStringType node = (SelStringType)obj;
          literal = new DefaultLiteralValue(
              node.getSelector(),
              Collections.singletonList(node.getStringValue()),
              false);
          found = true;
        } else {
          if (!found) {
            continue;
          }
          // Not a valid (literal) value instance
          break;
        }
        addLiteralValue(literal);
      } while (cursor.toNextSibling());

      // Check if there is a null selector entry which will correspond to
      // the default entry.  If not present, elect the first entry to be
      // the default with a null selector.
      Map<String, LiteralValue> selectorToLiteralValueMap = getSelectorToLiteralValueMap();
      if (!selectorToLiteralValueMap.containsKey(null)) {
        LiteralValue firstLiteral = selectorToLiteralValueMap.values().iterator().next();
        LiteralValue defaultLiteral = new DefaultLiteralValue(null, firstLiteral.getValues(), firstLiteral.isComplex());
        addLiteralValue(defaultLiteral);
      }
    } else {
      throw new IllegalStateException(new PropertyNotFoundException("value '" + getId()
          + "'is missing a default value property"));
View Full Code Here

TOP

Related Classes of gov.nist.scap.xccdf.document.LiteralValue

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.