Parses the configuration to get the type of memory.

@param configuration configuration object
@return type of memory
507162
public static MemoryType getMemoryType(Configuration configuration) {
		// check whether we use heap or off-heap memory
		final MemoryType memType;
		if (configuration.getBoolean(TaskManagerOptions.MEMORY_OFF_HEAP)) {
			memType = MemoryType.OFF_HEAP;
		} else {
			memType = MemoryType.HEAP;
		}
		return memType;
	}
70806
public static <T extends Trainable> T load(Class<T> aClass, String storageName, Configuration configuration) {
        try {
            Constructor<T> constructor = aClass.getDeclaredConstructor(String.class, Configuration.class);
            constructor.setAccessible(true);
            return constructor.newInstance(storageName, configuration);
        }
        catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException ex) {
            throw new RuntimeException(ex);
        }
    }
1264639
private static Class<?> getClassWithCaching(String className,
      Configuration conf) {
    Class<?> classs = cachedClassObjects.get(className);
    if (classs == null) {
      try {
        classs = conf.getClassByName(className);
        if (cachedClassObjects.size() < CACHE_MAX_SIZE) {
          cachedClassObjects.put(className, classs);
        }
      } catch (ClassNotFoundException e) {
        throw new RuntimeException("readObject can't find class " + className,
            e);
      }
    }
    // for sanity check if the class is not null
    if (classs == null) {
      throw new RuntimeException("readObject can't find class " + className);
    }
    return classs;
  }
768993
public ConfigSettings read()
	{

		ConfigSettings config = new ConfigSettings(ConfigEnum.IMPORT);

		String name;
		Node node;
		NodeList list = root.getChildNodes();

		int length = list.getLength();
		for (int i = 0; i < length; i++) {
			node = list.item(i);

			name = node.getNodeName().toUpperCase();

			if (name.equals(SECTION_MODE)) {
				parseModeConfig(node, config);
			}
			else if (name.equals(SECTION_EXTERNALS)) {
				parseExternalsConfig(node, config);
			}
			else if (name.equals(SECTION_INPUT)) {
				parseInputConfig(node, config);
			}
			else if (name.equals(SECTION_OUTPUT)) {
				parseOutputConfig(node, config);
			}
			else if (name.equals(SECTION_CACHE)) {
				parseCacheConfig(node, config);
			}
			else if (name.equals(SECTION_LOGGING)) {
				parseLoggingConfig(node, config);
			}
			else if (name.equals(SECTION_DEBUG)) {
				parseDebugConfig(node, config);
			}
			else if (name.equals(SECTION_FILTER)) {
				parseFilterConfig(node, config);
			}
		}

		return config;
	}
428778
public static <T extends Request<T>> RequestAllocator<T> inferFromConfig(RequestAllocatorConfig<T> configuration) {
    try {
      String alias = configuration.getLimitedScopeConfig().hasPath(ALLOCATOR_ALIAS_KEY) ?
          configuration.getLimitedScopeConfig().getString(ALLOCATOR_ALIAS_KEY) :
          BruteForceAllocator.Factory.class.getName();
      RequestAllocator.Factory allocatorFactory = new ClassAliasResolver<>(RequestAllocator.Factory.class).
          resolveClass(alias).newInstance();

      log.info("Using allocator factory " + allocatorFactory.getClass().getName());

      return allocatorFactory.createRequestAllocator(configuration);
    } catch (ReflectiveOperationException roe) {
      throw new RuntimeException(roe);
    }
  }
970503
protected void parseOptions(String configuration) {

        if (CmsStringUtil.isEmptyOrWhitespaceOnly(configuration)) {
            return;
        }
        if (!configuration.startsWith("{")) {
            // add curly braces if not present
            configuration = "{" + configuration + "}";
        }
        try {
            JSONObject json = new JSONObject(configuration);
            if (json.has(OPTION_LAT)) {
                setLat((float)json.getDouble(OPTION_LAT));
            }
            if (json.has(OPTION_LNG)) {
                setLng((float)json.getDouble(OPTION_LNG));
            }
            if (json.has(OPTION_ZOOM)) {
                setZoom(json.getInt(OPTION_ZOOM));
            }
            if (json.has(OPTION_WIDTH)) {
                setWidth(json.getInt(OPTION_WIDTH));
            }
            if (json.has(OPTION_HEIGHT)) {
                setHeight(json.getInt(OPTION_HEIGHT));
            }
            if (json.has(OPTION_TYPE)) {
                setType(MapType.valueOf(json.getString(OPTION_TYPE)));
            }
            if (json.has(OPTION_MODE)) {
                // do not use value of, as the client side string is not equal to the enumeration mode name
                setMode(MapMode.parseMode(json.getString(OPTION_MODE)));
            }
        } catch (JSONException e) {
            // something went wrong
            if (LOG.isErrorEnabled()) {
                LOG.error(e.getLocalizedMessage(), e);
            }
            return;
        }
    }
704782
private Configuration loadConfigurationFromMetadataBuffer(Buffer buffer) {
    if (buffer.position(12).readByte() == 1) {
      return new Configuration(
        buffer.readLong(),
        buffer.readLong(),
        buffer.readLong(),
        serializer.readObject(buffer)
      );
    }
    return null;
  }
513536
public static Configuration getConfiguration() {
	    if(configuration == null){
            try {
                configuration = (Configuration) getContext().getBean("configuration");
            } catch (BeansException e) {
                LOGGER.error("Can't load config. Error: {}",e ,e);
            }
        }
	    return configuration;
	}
82152
def parse_memory(memory):
    
    memory = str(memory)
    if 'None' in memory:
        return 2147483648 # toil's default
    try:
        import re
        raw_mem_split = re.split('([a-zA-Z]+)', memory)
        mem_split = []

        for r in raw_mem_split:
            if r:
                mem_split.append(r.replace(' ', ''))

        if len(mem_split) == 1:
            return int(memory)

        if len(mem_split) == 2:
            num = mem_split[0]
            unit = mem_split[1]
            return int(float(num) * return_bytes(unit))
        else:
            raise RuntimeError('Memory parsing failed: {}'.format(memory))
    except:
        return 2147483648
69360
public MithraRuntimeType parseConfiguration(InputStream mithraFileIs)
    {
        if(mithraFileIs == null)
        {
            throw new MithraBusinessException("Could not parse Mithra configuration, because the input stream is null.");
        }
        try
        {
            MithraRuntimeUnmarshaller unmarshaller = new MithraRuntimeUnmarshaller();
            unmarshaller.setValidateAttributes(false);
            return unmarshaller.parse(mithraFileIs, "");
        }
        catch (IOException e)
        {
            throw new MithraBusinessException("unable to parse ",e);
        }
        finally
        {
            try
            {
                mithraFileIs.close();
            }
            catch (IOException e)
            {
                getLogger().error("Could not close Mithra XML input stream", e);
            }
        }
    }
579306
public AbstractType<?> parse() throws SyntaxException, ConfigurationException
    {
        skipBlank();
        String name = readNextIdentifier();

        skipBlank();
        if (!isEOS() && str.charAt(idx) == '(')
            return getAbstractType(name, this);
        else
            return getAbstractType(name);
    }
75647
public LineType getLineType(final Configuration configuration)
    {
        if (this.isEmpty)
        {
            return LineType.EMPTY;
        }

        if (this.leading > 3)
        {
            return LineType.CODE;
        }

        if (this.value.charAt(this.leading) == '#')
        {
            return LineType.HEADLINE;
        }

        if (this.value.charAt(this.leading) == '>')
        {
            return LineType.BQUOTE;
        }

        if (configuration.forceExtendedProfile)
        {
            if (this.value.length() - this.leading - this.trailing > 2)
            {
                if (this.value.charAt(this.leading) == '`'
                        && this.countCharsStart('`', configuration.allowSpacesInFencedDelimiters) >= 3)
                {
                    return LineType.FENCED_CODE;
                }
                if (this.value.charAt(this.leading) == '~'
                        && this.countCharsStart('~', configuration.allowSpacesInFencedDelimiters) >= 3)
                {
                    return LineType.FENCED_CODE;
                }
            }
        }

        if (this.value.length() - this.leading - this.trailing > 2
                && (this.value.charAt(this.leading) == '*' || this.value.charAt(this.leading) == '-' || this.value
                        .charAt(this.leading) == '_'))
        {
            if (this.countChars(this.value.charAt(this.leading)) >= 3)
            {
                return LineType.HR;
            }
        }

        if (this.value.length() - this.leading >= 2 && this.value.charAt(this.leading + 1) == ' ')
        {
            switch (this.value.charAt(this.leading))
            {
            case '*':
            case '-':
            case '+':
                return LineType.ULIST;
            }
        }

        if (this.value.length() - this.leading >= 3 && Character.isDigit(this.value.charAt(this.leading)))
        {
            int i = this.leading + 1;
            while (i < this.value.length() && Character.isDigit(this.value.charAt(i)))
            {
                i++;
            }
            if (i + 1 < this.value.length() && this.value.charAt(i) == '.' && this.value.charAt(i + 1) == ' ')
            {
                return LineType.OLIST;
            }
        }

        if (this.value.charAt(this.leading) == '<')
        {
            if (this.checkHTML())
            {
                return LineType.XML;
            }
        }

        if (this.next != null && !this.next.isEmpty)
        {
            if ((this.next.value.charAt(0) == '-') && (this.next.countChars('-') > 0))
            {
                return LineType.HEADLINE2;
            }
            if ((this.next.value.charAt(0) == '=') && (this.next.countChars('=') > 0))
            {
                return LineType.HEADLINE1;
            }
        }

        return LineType.OTHER;
    }
350622
protected List<String> resolveScalacOptions( CompilerConfiguration configuration )
    {
        String scalacOptions = configuration.getScalacOptions();
        String sourceEncoding = configuration.getSourceEncoding();
        List<String> result = new ArrayList<String>( Arrays.asList( parseArgLine( scalacOptions ) ) );
        if ( !result.contains( "-encoding" ) && sourceEncoding != null && sourceEncoding.length() > 0 )
        {
            result.add( "-encoding" );
            result.add( sourceEncoding );
        }
        return result;
    }
1178271
public String serialize(String name, Configuration configuration) {
      try {
         ByteArrayOutputStream os = new ByteArrayOutputStream();
         serialize(os, name, configuration);
         return os.toString("UTF-8");
      } catch (Exception e) {
         throw new CacheConfigurationException(e);
      }
   }
526197
function parseStorageConfig() {
  var cfg, x, y, z,
      config = this.config.storages,
      storages = this.storages;
      
  if (!config) config = this.config.storages = {};

  if (Object.keys(config).length === 0) return;

  for (x in config) {
    cfg = config[x];
    for (y in cfg) {
      if (typeof cfg[y] == 'object') {
        if (typeof storages[x] == 'undefined') storages[x] = {};
        storages[x][y] = [x, cfg[y]];
      } else {
        storages[x] = [x, cfg];
        break;
      }
    }
  }
}
1042381
public static CmsGalleryConfigurationJSO parseConfiguration(String conf) {

        if (CmsStringUtil.isEmptyOrWhitespaceOnly(conf)) {
            conf = "{}";
        }
        return (CmsGalleryConfigurationJSO)CmsDomUtil.parseJSON(conf);
    }
925201
private long computeConfigurationLastModified(List<Resource> configurations) {
        long result = 0;
        for (Resource configuration : configurations) {
        	try {
                long currentConfigurationLastModified = configuration.lastModified();
                if (currentConfigurationLastModified > result) {
                    result = currentConfigurationLastModified;
                }
            } catch (IOException ioex) {
                logger.warn("Error while reading last configuration modification date.", ioex);
            }
        }
        return result;
    }