Create a plugin config object from JSON format.
@param inputStream the stream containing the JSON file.
@return the config object
482746
private CodePluginConfig parsePluginConfig(InputStream inputStream) {
        Gson gson = new Gson();
        CodePluginConfig config = gson.fromJson(new InputStreamReader(inputStream), CodePluginConfig.class);
        logger.log(Level.INFO, "Loaded configuration " + config);
        return config;
    }
233830
@SuppressWarnings("unchecked") // yaml.load API returns raw Map
  public static Map<String, Object> loadStream(InputStream inputStream) {
    LOG.fine("Reading config stream");

    Yaml yaml = new Yaml();
    Map<Object, Object> propsYaml = (Map<Object, Object>) yaml.load(inputStream);
    LOG.fine("Successfully read config");

    Map<String, Object> typedMap = new HashMap<>();
    for (Object key: propsYaml.keySet()) {
      typedMap.put(key.toString(), propsYaml.get(key));
    }

    return typedMap;
  }
763243
public final static <T> T readJson(InputStream jsonStream, Class<T> clazz)
    {
        ObjectMapper mapper = new ObjectMapper();
        try
        {
            if (jsonStream != null)
            {
                return mapper.readValue(jsonStream, clazz);
            }
            else
            {
                LOGGER.error("InputStream is null.");
                throw new KunderaException("InputStream is null.");
            }
        }
        catch (IOException e)
        {
            LOGGER.error("Error while mapping input stream to object. Caused By: ", e);
            throw new KunderaException("Error while mapping input stream to object. Caused By: ", e);
        }

    }
273165
public void load(InputStream in) {
    try {
      PropertiesConfiguration config = new PropertiesConfiguration();
      // disabled to prevent accumulo classpath value from being shortened
      config.setDelimiterParsingDisabled(true);
      config.load(in);
      ((CompositeConfiguration) internalConfig).addConfiguration(config);
    } catch (ConfigurationException e) {
      throw new IllegalArgumentException(e);
    }
  }
1203184
public <T> T read(final InputStream stream, final DataTypeDescriptor<T> descriptor) {
		try {
			return jsonFormat.read(stream, descriptor);
		} catch (Exception e) {
			throw propagate(e);
		}
	}
398165
public static EsriFeature FeatureFromJson(InputStream jsonInputStream) throws JsonParseException, IOException{
		JsonParser parser = jsonFactory.createJsonParser(jsonInputStream);
		return FeatureFromJson(parser);
	}
392501
public static NetworkConfig fromJsonObject(JsonObject jsonConfig) throws InvalidArgumentException, NetworkConfigurationException {

        // Sanity check
        if (jsonConfig == null) {
            throw new InvalidArgumentException("jsonConfig must be specified");
        }

        if (logger.isTraceEnabled()) {
            logger.trace(format("NetworkConfig.fromJsonObject: %s", jsonConfig.toString()));
        }

        return NetworkConfig.load(jsonConfig);
    }
1098503
@SuppressWarnings("unchecked")
  public static <S extends Serializable> S deserialize(InputStream inputStream) throws IOException {
    try {
      return (S) new ObjectInputStream(inputStream).readObject();
    } catch (ClassNotFoundException exception) {
      IOException ioe = new IOException("Failed to deserialize object");
      ioe.initCause(exception);
      throw ioe;
    } finally {
      inputStream.close();
    }
  }
1303588
public T get(InputStream stream) throws IOException, JsonFormatException {
		JsonPullParser parser = JsonPullParser.newParser(stream);
		return get(parser, null);
	}
1188208
public Reflections collect(final InputStream inputStream) {
        try {
            merge(configuration.getSerializer().read(inputStream));
            if (log != null) log.info("Reflections collected metadata from input stream using serializer " + configuration.getSerializer().getClass().getName());
        } catch (Exception ex) {
            throw new ReflectionsException("could not merge input stream", ex);
        }

        return this;
    }
1325894
protected static Properties loadConfig(String source, InputStream is) {
    try {
      Properties p = new Properties();
      p.load(is);
      // trim the value as it may have trailing white-space
      Set<String> keys = p.stringPropertyNames();
      for(String key: keys) {
        p.setProperty(key, p.getProperty(key).trim());
      }
      return p;
    } catch (IllegalArgumentException iae) {
      throw iae;
    } catch (Exception ex) {
      throw new IllegalArgumentException("Failed to load configuration from [" + source + "]");
    }
  }
134436
public static Properties load(InputStream inputStream) {
        Properties configs = new Properties();
        try {
            configs.load(new UnicodeInputStream(inputStream).skipBOM());
        } catch (IOException e) {
            LOGGER.warn("Load properties from inputStream error!", e);
        }
        return configs;
    }
1372325
public static Document getDocument(InputStream inputStream) {
        Document result = null;

        try {
            // memory optimization over minor performance sacrifice
            synchronized (XmlRepositoryFactory.class) {
                if (documentBuilder == null) {
                    documentBuilder = builderFactory.newDocumentBuilder();
                }

                result = documentBuilder.parse(inputStream);
            }
        } catch (ParserConfigurationException ex) {
            throw new MjdbcRuntimeException(ex);
        } catch (SAXException ex) {
            throw new MjdbcRuntimeException(ex);
        } catch (IOException ex) {
            throw new MjdbcRuntimeException(ex);
        }

        return result;
    }
904653
@Override
  public Set<ConfigStream> getConfigStreams() throws IOException {
    Set<ConfigStream> configStreams = Sets.newHashSet();
    for (String configPath : getDeployableConfigPaths()) {
      configStreams.add(new ConfigStream(Optional.of(getConfigStream(configPath)),
          StringUtils.substringAfter(Strings.nullToEmpty(configPath), this.classpathRootName + "/")));
    }
    return configStreams;
  }
994525
public Object parse(InputStream inputStream) {
        if (inputStream == null) {
            throw new IllegalArgumentException("inputStream must not be null");
        }

        Object content;
        JsonParser parser = createParser();
        content = parser.parse(inputStream);
        return content;
    }
787909
private static Reader loadInputStream(InputStream propertiesStream) throws IOException {
        StringBuilder buff = new StringBuilder();

        try (InputStreamReader isr = new InputStreamReader(propertiesStream, Charset.defaultCharset());
                BufferedReader reader = new BufferedReader(isr)) {
            String line;
            while ((line = reader.readLine()) != null) {
                buff.append(line).append("\n");
            }
        }

        return new StringReader(StrSubstitutor.replaceSystemProperties(buff.toString()));
    }
997708
@SuppressWarnings("unchecked")
    @Override
    public T readConfig(InputStream fileAsStream) throws ConfigurationException {
        XStream xstream = new XStream(new StaxDriver());
        xstream.alias("configuration", clazz);
        return (T) xstream.fromXML(fileAsStream);
    }