Package com.eclipsesource.json

Examples of com.eclipsesource.json.JsonObject


  {
    try
    {
      System.out.println( "Using config : " + new File( configFile ).getName() );

      JsonObject config = Util.getJsonFromFile( configFile );

      mModel.setClassPackage( config.get( "package" ).asString() );
      mModel.setContentAuthority( config.get( "authority" ).asString() );
      mModel.setDbName( config.get( "databaseName" ).asString() );
      mModel.setDbVersion( config.get( "databaseVersion" ).asInt() );
      mModel.setContentProviderName( config.get( "contentproviderName" ).asString() );

    } catch ( IOException ex )
    {
      System.err.println( "Couldn't parse the config json file." );
      System.exit( 1 );
View Full Code Here


    System.out.println("Trying to parse " + file.getName());

    try
    {
      JsonObject json = Util.getJsonFromFile( file.getPath() );

      boolean containsFields = json.names().contains( "fields" );
      boolean containsSelects = json.names().contains( "selects" );

      if ( containsFields )
      {
        parseTableFromFile( json, name );
      } else if ( containsSelects )
View Full Code Here

      table.name = name.toLowerCase();
      try
      {
        for ( JsonValue jsoninfo : jsontable.get( "fields" ).asArray() )
        {
          JsonObject info = (JsonObject) jsoninfo;
          String type = info.get( "type" ).asString().toLowerCase();
          if ( type.equals( "autoincrement" ) )
          {
            table.setPrimaryKey( type, info.get( "name" ).asString() );
          }

          ArrayList<Constraint> constraints = new ArrayList<Constraint>();
          if ( info.names().contains( "constraints" ) )
          {
            for ( JsonValue jsonconstaint : info.get( "constraints" ).asArray() )
            {
              JsonObject constraint = (JsonObject) jsonconstaint;
              String definition = constraint.get( "definition" ).asString();
              if ( definition.toLowerCase().contains( "primary key" ) )
              {
                // skip if primary key already set
                if ( table.hasPrimaryKey() )
                {
                  continue;
                }

                final Field field = table.getFieldByName( constraint.get( "name" ).asString() );
                if ( field != null )
                {
                  table.setPrimaryKey( field );
                }
              }
              constraints.add( new Constraint( constraint.names().contains( "name" ) ? constraint.get( "name" ).asString() : null, definition ) );
            }
          }
          table.addField( type, info.get( "name" ).asString(), constraints );
        }
      } catch ( NullPointerException e )
      {
        throw new ParserException( "Couldn't parse the fields in this table." );
      }
      if ( jsontable.names().contains( "constraints" ) )
      {
        try
        {
          for ( JsonValue jsoninfo : jsontable.get( "constraints" ).asArray() )
          {
            JsonObject info = (JsonObject) jsoninfo;
            String definition = info.get( "definition" ).asString();
            if ( definition.toLowerCase().contains( "primary key" ) )
            {
              // skip if primary key already set
              if ( table.hasPrimaryKey() )
              {
                continue;
              }

              final Field field = table.getFieldByName( info.get( "name" ).asString() );
              if ( field != null )
              {
                table.setPrimaryKey( field );
              }
            }
            table.addConstraint( info.names().contains( "name" ) ? info.get( "name" ).asString() : null, definition );
          }
        } catch ( NullPointerException e )
        {
          throw new ParserException( "Couldn't parse the constraints in this table." );
        }
View Full Code Here

      view.name = name.toLowerCase();
      try
      {
        for ( JsonValue jsoninfo : jsonview.get( "selects" ).asArray() )
        {
          JsonObject info = (JsonObject) jsoninfo;
          view.addSelect( (info.names().contains( "as" )) ? info.get( "as" ).asString() : null, info.get( "select" ).asString() );
        }
      } catch ( NullPointerException e )
      {
        throw new ParserException( "Couldn't parse the selects in this view." );
      }

      try
      {
        for ( JsonValue jsoninfo : jsonview.get( "from" ).asArray() )
        {
          view.addFromTable( jsoninfo.asString() );
        }
      } catch ( NullPointerException e )
      {
        throw new ParserException( "Couldn't parse the from tables in this view." );
      }

      try
      {
        for ( JsonValue jsoninfo : jsonview.get( "on" ).asArray() )
        {
          view.addJoinOn( jsoninfo.asString() );
        }
      } catch ( NullPointerException e )
      {
        throw new ParserException( "Couldn't parse the fields on which to join in this view." );
      }
      try
      {
        if ( jsonview.names().contains( "order" ) )
        {
          for ( JsonValue jsoninfo : jsonview.get( "order" ).asArray() )
          {
            JsonObject info = (JsonObject) jsoninfo;
            view.addOrder( info.get( "by" ).asString(), (info.names().contains( "sort" )) ? info.get( "sort" ).asString() : "ASC" );
          }
        }
      } catch ( NullPointerException e )
      {
        throw new ParserException( "Couldn't parse the ordering in this view." );
View Full Code Here

      new Packr().pack(config);
    } else {
      if(args.length == 0) {
        printHelp();
      } else {
        JsonObject json = JsonObject.readFrom(FileUtils.readFileToString(new File(args[0])));
        Config config = new Config();
        config.platform = Platform.valueOf(json.get("platform").asString());
        config.jdk = json.get("jdk").asString();
        config.executable = json.get("executable").asString();
        config.jar = json.get("appjar").asString();
        config.mainClass = json.get("mainclass").asString();
        if(json.get("vmargs") != null) {
          for(JsonValue val: json.get("vmargs").asArray()) {
            config.vmArgs.add(val.asString());
          }
        }
        config.outDir = json.get("outdir").asString();
        if(json.get("minimizeJre") != null) {
          config.minimizeJre = json.get("minimizeJre").asBoolean();
        }
        if(json.get("resources") != null) {
          config.resources = toStringArray(json.get("resources").asArray());
        }
        new Packr().pack(config);
      }
    }
  }
View Full Code Here

        return Collections.emptyList();
    }

    @Override
    public void writeResponse(ManagementCenterService mcs, JsonObject root) {
        final JsonObject result = new JsonObject();
        JsonArray logs = new JsonArray();
        result.add("logs", logs);
        root.add("result", result);
    }
View Full Code Here

        root.add("result", result);
    }

    @Override
    public JsonObject toJson() {
        return new JsonObject();
    }
View Full Code Here

        this.proxyCount = proxyCount;
    }

    @Override
    public JsonObject toJson() {
        final JsonObject root = new JsonObject();
        root.add("proxyCount", proxyCount);
        return root;
    }
View Full Code Here

        this.clientType = clientType;
    }

    @Override
    public JsonObject toJson() {
        final JsonObject root = new JsonObject();
        root.add("uuid", uuid);
        root.add("address", address);
        root.add("clientType", clientType);
        return root;
    }
View Full Code Here

        return JsonUtil.getString(json, "configXmlString", "Error while reading response " + MemberConfigRequest.class.getName());
    }

    @Override
    public void writeResponse(ManagementCenterService mcs, JsonObject root) {
        final JsonObject result = new JsonObject();
        ConfigXmlGenerator configXmlGenerator = new ConfigXmlGenerator(true);
        Config config = mcs.getHazelcastInstance().getConfig();
        String configXmlString = configXmlGenerator.generate(config);
        result.add("configXmlString", configXmlString);
        root.add("result", result);
    }
View Full Code Here

TOP

Related Classes of com.eclipsesource.json.JsonObject

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.