Package org.apache.commons.collections.bidimap

Examples of org.apache.commons.collections.bidimap.TreeBidiMap$Node


    return getLiteral(n, false);
  }

  public static Literal getLiteral(final Node node, final boolean allowLazyLiteral) {
    Literal literal = null;
    Node n = node;

    if (n instanceof ASTNIL) {
      try {
        literal = (allowLazyLiteral) ? LiteralFactory
            .createURILiteral("<http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>")
            : LiteralFactory
                .createURILiteralWithoutLazyLiteral("<http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>");
      } catch (final URISyntaxException e1) {
        e1.printStackTrace();
      }
    } else if (n instanceof ASTBlankNode) {
      final ASTBlankNode blankNode = (ASTBlankNode) n;
      final String name = blankNode.getIdentifier();
      literal = (allowLazyLiteral) ? LiteralFactory
          .createAnonymousLiteral(name) : LiteralFactory
          .createAnonymousLiteralWithoutLazyLiteral(name);
    } else if (n instanceof ASTQuotedURIRef) {
      final ASTQuotedURIRef uri = (ASTQuotedURIRef) n;
      final String name = uri.getQRef();

      if (URILiteral.isURI("<" + name + ">")) {
        try {
          literal = (allowLazyLiteral) ? LiteralFactory
              .createURILiteral("<" + name + ">")
              : LiteralFactory
                  .createURILiteralWithoutLazyLiteral("<"
                      + name + ">");
        } catch (final Exception e) {
          literal = (allowLazyLiteral) ? LiteralFactory
              .createLiteral("<" + name + ">") : LiteralFactory
              .createLiteralWithoutLazyLiteral("<" + name + ">");
        }
      } else {
        literal = (allowLazyLiteral) ? LiteralFactory.createLiteral("<"
            + name + ">") : LiteralFactory
            .createLiteralWithoutLazyLiteral("<" + name + ">");
      }
    } else if (n instanceof ASTRDFLiteral) {
      n = n.jjtGetChild(0);
    }

    if (literal != null) {
      return literal;
    }

    if (n instanceof ASTStringLiteral) {
      final ASTStringLiteral lit = (ASTStringLiteral) n;
      final String quotedContent = lit.getStringLiteral();

      literal = (allowLazyLiteral) ?
          LiteralFactory.createLiteral(quotedContent)
          : LiteralFactory.createLiteralWithoutLazyLiteral(quotedContent);
    } else if (n instanceof ASTInteger) {
      final ASTInteger lit = (ASTInteger) n;
      final String content = String.valueOf(lit.getValue());

      try {
        literal = (allowLazyLiteral) ? LiteralFactory
            .createTypedLiteral("\"" + content + "\"",
                "<http://www.w3.org/2001/XMLSchema#integer>")
            : TypedLiteralOriginalContent.createTypedLiteral("\""
                + content + "\"",
                "<http://www.w3.org/2001/XMLSchema#integer>");
      } catch (final URISyntaxException e) {
        literal = (allowLazyLiteral) ? LiteralFactory
            .createLiteral(content) : LiteralFactory
            .createLiteralWithoutLazyLiteral(content);
      }
    } else if (n instanceof ASTFloatingPoint) {
      final ASTFloatingPoint lit = (ASTFloatingPoint) n;
      final String content = lit.getValue();

      try {
        if (content.contains("e") || content.contains("E")) {
          literal = (allowLazyLiteral) ? LiteralFactory
              .createTypedLiteral("\"" + content + "\"",
                  "<http://www.w3.org/2001/XMLSchema#double>")
              : TypedLiteralOriginalContent
                  .createTypedLiteral("\"" + content + "\"",
                      "<http://www.w3.org/2001/XMLSchema#double>");
        } else {
          literal = (allowLazyLiteral) ? LiteralFactory
              .createTypedLiteral("\"" + content + "\"",
                  "<http://www.w3.org/2001/XMLSchema#decimal>")
              : TypedLiteralOriginalContent
                  .createTypedLiteral("\"" + content + "\"",
                      "<http://www.w3.org/2001/XMLSchema#decimal>");
        }
      } catch (final URISyntaxException e) {
        literal = (allowLazyLiteral) ? LiteralFactory
            .createLiteral(content) : LiteralFactory
            .createLiteralWithoutLazyLiteral(content);
      }
    } else if (n instanceof ASTBooleanLiteral) {
      final String content = ((ASTBooleanLiteral) n).getState() + "";

      try {
        literal = (allowLazyLiteral) ? LiteralFactory
            .createTypedLiteral("\"" + content + "\"",
                "<http://www.w3.org/2001/XMLSchema#boolean>")
            : TypedLiteralOriginalContent.createTypedLiteral("\""
                + content + "\"",
                "<http://www.w3.org/2001/XMLSchema#boolean>");
      } catch (final URISyntaxException e) {
        literal = (allowLazyLiteral) ? LiteralFactory
            .createLiteral(content) : LiteralFactory
            .createLiteralWithoutLazyLiteral(content);
      }
    } else if (n instanceof ASTDoubleCircumflex) {
      if (n.jjtGetNumChildren() != 2) {
        System.err.println(n + " is expected to have 2 children!");
      } else {
        final String content = getLiteral(n.jjtGetChild(0), false).toString();
        final String type = getLiteral(n.jjtGetChild(1), false).toString();

        try {
          literal = (allowLazyLiteral) ? LiteralFactory
              .createTypedLiteral(content, type)
              : TypedLiteralOriginalContent.createTypedLiteral(
                  content, type);
        } catch (final Exception e) {
          literal = (allowLazyLiteral) ? LiteralFactory
              .createLiteral(content + "^^" + type)
              : LiteralFactory
                  .createLiteralWithoutLazyLiteral(content
                      + "^^" + type);
        }
      }
    } else if (n instanceof ASTLangTag) {
      final String content = getLiteral(n.jjtGetChild(0), false).toString();
      final String lang = ((ASTLangTag) n).getLangTag();
      literal = (allowLazyLiteral) ? LiteralFactory
          .createLanguageTaggedLiteral(content, lang)
          : LanguageTaggedLiteralOriginalLanguage
              .createLanguageTaggedLiteral(content, lang);
    } else if (n instanceof ASTQName) {
      final ASTQName uri = (ASTQName) n;
      final String namespace = uri.getNameSpace();
      final String localName = uri.getLocalName();

      final String name = namespace + localName;

      if (URILiteral.isURI("<" + name + ">")) {
        try {
          literal = (allowLazyLiteral) ? LiteralFactory
              .createURILiteral("<" + name + ">")
              : LiteralFactory
                  .createURILiteralWithoutLazyLiteral("<"
                      + name + ">");
        } catch (final Exception e) {
          literal = (allowLazyLiteral) ? LiteralFactory
              .createLiteral("<" + name + ">") : LiteralFactory
              .createLiteralWithoutLazyLiteral("<" + name + ">");
        }
      } else {
        literal = (allowLazyLiteral) ? LiteralFactory.createLiteral("<"
            + name + ">") : LiteralFactory
            .createLiteralWithoutLazyLiteral("<" + name + ">");
      }
    } else if(n instanceof ASTObjectList){
      literal = getLiteral(n.jjtGetChild(0), allowLazyLiteral);
    } else {
      System.err.println("Unexpected type! "
          + n.getClass().getSimpleName());
    }

    return literal;
  }
View Full Code Here


    protected void activate(final ComponentContext componentContext) {
        this.componentContext = componentContext;
        this.rootProviderEntry.setEventAdmin(this.eventAdmin);
        final Dictionary<?, ?> properties = componentContext.getProperties();

        final BidiMap virtuals = new TreeBidiMap();
        final String[] virtualList = PropertiesUtil.toStringArray(properties.get(PROP_VIRTUAL));
        for (int i = 0; virtualList != null && i < virtualList.length; i++) {
            final String[] parts = Mapping.split(virtualList[i]);
            virtuals.put(parts[0], parts[2]);
        }
        virtualURLMap = virtuals;

        final List<Mapping> maps = new ArrayList<Mapping>();
        final String[] mappingList = (String[]) properties.get(PROP_MAPPING);
View Full Code Here

        String[] uuids = new String[2];
        Map fileResourceMap = (Map) configurationContext.getProperty(
                ServerConstants.FILE_RESOURCE_MAP);
        if (fileResourceMap == null) {
            fileResourceMap = new TreeBidiMap();
            configurationContext.setProperty(ServerConstants.FILE_RESOURCE_MAP, fileResourceMap);
        }

        try {
            for (Object o : fileItemsMap.keySet()) {
View Full Code Here

            // Creating the Client side configuration context
            clientConfigContext = getClientConfigurationContext();

            //TOa house keeping taskDO add this map to a house keeping task
            //Adding FILE_RESOURCE_MAP
            Object property = new TreeBidiMap();
            clientConfigContext.setProperty(ServerConstants.FILE_RESOURCE_MAP, property);
            clientConfigContext.setContextRoot(carbonContextRoot);

            //Deploying Web service which resides in bundles
            Axis2ServiceRegistry serviceRegistry = new Axis2ServiceRegistry(serverConfigContext);
View Full Code Here

                    Long.parseLong(serverConfig.
                            getFirstProperty("HouseKeeping.Interval")) * 60 * 1000;
            Object property =
                    configurationContext.getProperty(ServerConstants.FILE_RESOURCE_MAP);
            if (property == null) {
                property = new TreeBidiMap();
                configurationContext.setProperty(ServerConstants.FILE_RESOURCE_MAP, property);
            }
            houseKeepingTimer.
                    scheduleAtFixedRate(new HouseKeepingTask(serverWorkDir, (BidiMap) property),
                            houseKeepingInterval,
View Full Code Here

        try {
          Map fileResourceMap =
                (Map) configurationContext
                        .getProperty(ServerConstants.FILE_RESOURCE_MAP);
          if (fileResourceMap == null) {
            fileResourceMap = new TreeBidiMap();
            configurationContext.setProperty(ServerConstants.FILE_RESOURCE_MAP,
                                             fileResourceMap);
          }
            List<FileItemData> fileItems = getAllFileItems();
            String filePaths = "";
View Full Code Here

        this.componentContext = componentContext;
        this.serviceReference = componentContext.getServiceReference();

        Dictionary<?, ?> properties = componentContext.getProperties();

        BidiMap virtuals = new TreeBidiMap();
        String[] virtualList = (String[]) properties.get(PROP_VIRTUAL);
        for (int i = 0; virtualList != null && i < virtualList.length; i++) {
            String[] parts = Mapping.split(virtualList[i]);
            virtuals.put(parts[0], parts[2]);
        }
        virtualURLMap = virtuals;

        List<Mapping> maps = new ArrayList<Mapping>();
        String[] mappingList = (String[]) properties.get(PROP_MAPPING);
View Full Code Here

  @Override
  public HmmModel clone() throws CloneNotSupportedException {
    super.clone();
    HmmModel model = new HmmModel(transitionMatrix.clone(), emissionMatrix.clone(), initialProbabilities.clone());
    if (hiddenStateNames != null) {
      model.hiddenStateNames = new TreeBidiMap(hiddenStateNames);
    }
    if (outputStateNames != null) {
      model.outputStateNames = new TreeBidiMap(outputStateNames);
    }
    return model;
  }
View Full Code Here

   *
   * @param stateNames names of hidden states.
   */
  public void registerHiddenStateNames(String[] stateNames) {
    if (stateNames != null) {
      hiddenStateNames = new TreeBidiMap();
      for (int i = 0; i < stateNames.length; ++i) {
        hiddenStateNames.put(stateNames[i], i);
      }
    }
  }
View Full Code Here

   *
   * @param stateNames <String,Integer> Map that assigns each state name an integer ID
   */
  public void registerHiddenStateNames(Map<String, Integer> stateNames) {
    if (stateNames != null) {
      hiddenStateNames = new TreeBidiMap(stateNames);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.commons.collections.bidimap.TreeBidiMap$Node

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.