Creates a new {@link MetricReader}.

@param options the options for {@link MetricReader}.
@return a new {@link MetricReader}.
@since 0.19
515446
public static MetricReader create(Options options) {
    checkNotNull(options, "options");
    return new MetricReader(
        checkNotNull(options.getMetricProducerManager(), "metricProducerManager"),
        checkNotNull(options.getSpanName(), "spanName"));
  }
617149
@Nonnull
  public static <T> UBLTRReaderBuilder <T> create (@Nonnull final Class <T> aClass)
  {
    return new UBLTRReaderBuilder <> (aClass);
  }
709109
public Reader create(InputStream is, String javaEncoding)
    throws UnsupportedEncodingException
  {
    if (Charset.isSupported(javaEncoding)) {
      Charset charset = Charset.forName(javaEncoding);
    
      return new InputStreamReader(is, charset);
    }
    else {
      // RSN-274, Charset doesn't support all java.io encoding
      return new InputStreamReader(is, javaEncoding);
    }
  }
1314185
@Override
    public int read() throws IOException {
        if (metrics != null) {
            metrics.startEvent(Field.HttpSocketReadTime);
        }
        try {
            return in.read();
        } finally {
            if (metrics != null) {
                metrics.endEvent(Field.HttpSocketReadTime);
            }
        }
    }
774398
public static MetricRegistryConfiguration fromConfiguration(Configuration configuration) {
		ScopeFormats scopeFormats;
		try {
			scopeFormats = ScopeFormats.fromConfig(configuration);
		} catch (Exception e) {
			LOG.warn("Failed to parse scope format, using default scope formats", e);
			scopeFormats = ScopeFormats.fromConfig(new Configuration());
		}

		char delim;
		try {
			delim = configuration.getString(MetricOptions.SCOPE_DELIMITER).charAt(0);
		} catch (Exception e) {
			LOG.warn("Failed to parse delimiter, using default delimiter.", e);
			delim = '.';
		}

		final long maximumFrameSize = AkkaRpcServiceUtils.extractMaximumFramesize(configuration);

		// padding to account for serialization overhead
		final long messageSizeLimitPadding = 256;

		return new MetricRegistryConfiguration(scopeFormats, delim, maximumFrameSize - messageSizeLimitPadding);
	}
88588
@SuppressWarnings("unchecked")
  private void gatherOneMetric(
      String metricName,
      Metrics.MetricPublisherPublishMessage.Builder builder) {
    Object metricValue = metrics.get(metricName).getValueAndReset();
    // Decide how to handle the metric based on type
    if (metricValue == null) {
      return;
    }
    if (metricValue instanceof Map) {
      for (Map.Entry<Object, Object> entry : ((Map<Object, Object>) metricValue).entrySet()) {
        if (entry.getKey() != null && entry.getValue() != null) {
          addDataToMetricPublisher(
              builder, metricName + "/" + entry.getKey().toString(), entry.getValue());
        }
      }
    } else if (metricValue instanceof Collection) {
      int index = 0;
      for (Object value : (Collection) metricValue) {
        addDataToMetricPublisher(builder, metricName + "/" + (index++), value);
      }
    } else {
      addDataToMetricPublisher(builder, metricName, metricValue);
    }
  }
1041245
@Nonnull
  public static <T> UBL22ReaderBuilder <T> create (@Nonnull final Class <T> aClass)
  {
    return new UBL22ReaderBuilder<> (aClass);
  }
1356071
public static Reader getResourceAsReader(ClassLoader loader, String resource) throws IOException {
        return new InputStreamReader(getResourceAsStream(loader, resource));
    }
742543
static BitReader newBitReader(BitStore store, final int finalPos, final int initialPos) {
		if (store == null) throw new IllegalArgumentException("null store");
		if (finalPos < 0) throw new IllegalArgumentException("negative finalPos");
		if (initialPos > store.size()) throw new IllegalArgumentException("initialPos too large");

		return new BitReader() {
			int pos = initialPos;

			@Override
			public long getPosition() {
				return initialPos - pos;
			}

			@Override
			public long setPosition(long newPosition) {
				if (newPosition < finalPos) {
					pos = finalPos - initialPos;
					return finalPos;
				}
				if (newPosition >= initialPos) {
					pos = 0;
					return initialPos;
				}
				pos = initialPos - (int) newPosition;
				return newPosition;
			}

			@Override
			public boolean readBoolean() throws BitStreamException {
				if (pos <= 0) throw new EndOfBitStreamException();
				return store.getBit(--pos);
			}

			@Override
			public int readBit() throws BitStreamException {
				return readBoolean() ? 1 : 0;
			}

			@Override
			public long readLong(int count) throws BitStreamException {
				if (count < 0) throw new IllegalArgumentException();
				if (count > 64) throw new IllegalArgumentException();
				pos -= count;
				if (pos < 0) throw new EndOfBitStreamException();
				return store.getBits(pos, count);
			}

			@Override
			public int read(int count) throws BitStreamException {
				if (count < 0) throw new IllegalArgumentException();
				if (count > 32) throw new IllegalArgumentException();
				pos -= count;
				if (pos < 0) throw new EndOfBitStreamException();
				return (int) store.getBits(pos, count);
			}

			@Override
			public int readUntil(boolean one) throws BitStreamException {
				//TODO efficient implementation needs next/previous bit support on BitStore
				return BitReader.super.readUntil(one);
			}

			@Override
			public BigInteger readBigInt(int count) throws BitStreamException {
				switch(count) {
				case 0 : return BigInteger.ZERO;
				case 1 : return readBoolean() ? BigInteger.ONE : BigInteger.ZERO;
				default :
					final int from = pos - count;
					if (from < 0) throw new EndOfBitStreamException();
					final int to = pos;
					pos = from;
					return store.range(from, to).toBigInteger();
				}
			}
		};
	}
544220
public static Reader createReader(InputStream inputStream,String encoding)
    {
        //get encoding
        String updatedEncoding=IOHelper.getEncodingToUse(encoding);
        
        //create reader
        Reader reader=null;
        try
        {
            reader=new InputStreamReader(inputStream,updatedEncoding);
        }
        catch(UnsupportedEncodingException exception)
        {
            throw new FaxException("Unable to create reader, unsupported encoding: "+encoding,exception);
        }
        
        return reader;
    }
1055371
public static Operator buildOperator(OperatorDesc operatorDesc, MetricRegistry metricRegistry, String planPath, FeedPartition feedPartition) {
    Operator operator = null;
    NitFactory nitFactory = new NitFactory();
    NitDesc nitDesc = nitDescFromDynamic(operatorDesc);
    try {
      if (nitDesc.getSpec() == NitDesc.NitSpec.GROOVY_CLOSURE){
        operator = new GroovyOperator((Closure) nitFactory.construct(nitDesc));
      } else {
        operator = nitFactory.construct(nitDesc);
      }
    } catch (NitException e) {
      throw new RuntimeException(e);
    }
    operator.setProperties(operatorDesc.getParameters());
    operator.setMetricRegistry(metricRegistry);
    operator.setPartitionId(feedPartition.getPartitionId());
    String myName = operatorDesc.getName();
    if (myName == null){
      myName = operatorDesc.getTheClass();
      if (myName.indexOf(".") > -1){
        String[] parts = myName.split("\\.");
        myName = parts[parts.length-1];
      }
    }
    operator.setPath(planPath + "." + myName);
    return operator;
  }
1357667
public static function createFromSource($source, $type, array $options = []) {
		if (isset(self::$readers[$type])) {
			$reader = self::$readers[$type];
		} else {
			$class  = self::READERS_NAMESPACE . '\\' . ucfirst($type);
			$reader = new $class();

			if (! $reader instanceof ReaderInterface) {
				throw new InvalidReader('Reader must implement the "ReaderInterface"');
			}
			
			self::$readers[$type] = $reader;
		}
		
		// Read only lock resolve
		if (isset($options[self::OPTION_READONLY])) {
			$readOnly = (bool) $options[self::OPTION_READONLY];
			unset($options[self::OPTION_READONLY]);
		} else {
			$readOnly = true;
		}
		
		return self::create($reader->parse($source, $options), $readOnly);
	}
636024
public MetricsProvider getProvider(String name) throws MetricsException {
		if(container.containsKey(name)) {
			return (MetricsProvider) container.get(name);
		} else {
			throw new MetricsException("No MetricsProvider with name: " + name);
		}
	}
373243
public static <I extends Request, O extends Response>
    Function<Client<I, O>, MetricCollectingClient<I, O>> newDecorator(
            MeterIdPrefixFunction meterIdPrefixFunction) {

        requireNonNull(meterIdPrefixFunction, "meterIdPrefixFunction");
        return delegate -> new MetricCollectingClient<>(delegate, meterIdPrefixFunction);
    }
868387
private static Options constructOptions() {
    Option id = Option.builder()
        .desc("Metrics manager id")
        .longOpt("id")
        .hasArgs()
        .argName("id")
        .required()
        .build();

    Option port = Option.builder()
        .desc("Metrics manager port")
        .longOpt("port")
        .hasArgs()
        .argName("port")
        .required()
        .build();

    Option topology = Option.builder()
        .desc("The name of the topology to collect metrics from")
        .longOpt("topology")
        .hasArgs()
        .argName("topology")
        .required()
        .build();

    Option topologyId = Option.builder()
        .desc("The name of the topology to collect metrics from")
        .longOpt("topology-id")
        .hasArgs()
        .argName("topologyId")
        .required()
        .build();

    Option cluster = Option.builder()
        .desc("The name of the topology to collect metrics from")
        .longOpt("cluster")
        .hasArgs()
        .argName("cluster")
        .required()
        .build();

    Option role = Option.builder()
        .desc("The name of the topology to collect metrics from")
        .longOpt("role")
        .hasArgs()
        .argName("role")
        .required()
        .build();

    Option environment = Option.builder()
        .desc("The name of the topology to collect metrics from")
        .longOpt("environment")
        .hasArgs()
        .argName("environment")
        .required()
        .build();

    Option sinkConfig = Option.builder()
        .desc("The name of the topology to collect metrics from")
        .longOpt("sink-config-file")
        .hasArgs()
        .argName("sink config file")
        .required()
        .build();

    Option systemConfig = Option.builder()
        .desc("The name of the topology to collect metrics from")
        .longOpt("system-config-file")
        .hasArgs()
        .argName("system config file")
        .required()
        .build();

    Option overrideConfig = Option.builder()
        .desc("The name of the topology to collect metrics from")
        .longOpt("override-config-file")
        .hasArgs()
        .argName("override config file")
        .required()
        .build();

    return new Options()
        .addOption(id)
        .addOption(port)
        .addOption(topology)
        .addOption(topologyId)
        .addOption(cluster)
        .addOption(role)
        .addOption(environment)
        .addOption(systemConfig)
        .addOption(overrideConfig)
        .addOption(sinkConfig);
  }
369004
public <T> HttpClientRequest.Builder<T> options(final URI uri, final HttpClientResponseHandler<T> httpHandler)
    {
        return new HttpClientRequest.Builder<T>(httpClientFactory, HttpClientMethod.OPTIONS, uri, httpHandler);
    }
135544
public static PropertiesConfigurationSource create(Reader reader, int priority)
      throws ConfigurationException, IOException {
    return new PropertiesConfigurationSource(createPropertiesConfiguration(reader), priority);
  }