Parses metadata from a collection of repositories.

@param source the {@link RepositoryCollection} containing the metadata to parse
@return {@link IntermediateParseResults} containing the parsed metadata
541502
private IntermediateParseResults getEntityTypeFromSource(RepositoryCollection source) {
    IntermediateParseResults intermediateResults = parseTagsSheet(source.getRepository(EMX_TAGS));

    parsePackagesSheet(source.getRepository(EMX_PACKAGES), intermediateResults);
    parseEntitiesSheet(source.getRepository(EMX_ENTITIES), intermediateResults);
    parseAttributesSheet(source.getRepository(EMX_ATTRIBUTES), intermediateResults);
    reiterateToMapRefEntity(source.getRepository(EMX_ATTRIBUTES), intermediateResults);

    // languages tab
    if (source.hasRepository(EMX_LANGUAGES))
      parseLanguages(source.getRepository(EMX_LANGUAGES), intermediateResults);

    // i18nstrings tab
    if (source.hasRepository(EMX_I18NSTRINGS))
      parseI18nStrings(source.getRepository(EMX_I18NSTRINGS), intermediateResults);

    postProcessMetadata(intermediateResults);

    return intermediateResults;
  }
1137739
public static <T> List<T> wrapList(final T... source) {
        val list = new ArrayList<T>();
        addToCollection(list, source);
        return list;
    }
386589
@SuppressWarnings("unchecked")
    public static Set<Repository> toRepositoryList(Vector<Object> repositoriesParams)
    {
        Set<Repository> repositories = new TreeSet<Repository>();
        for(Object repositoryParams : repositoriesParams)
        {
            repositories.add(toRepository((Vector<Object>)repositoryParams));
        }
        
        return repositories;
    }
1031290
public DescriptorRepository readDescriptorRepository(String fileName)
    {
        try
        {
            RepositoryPersistor persistor = new RepositoryPersistor();
            return persistor.readDescriptorRepository(fileName);
        }
        catch (Exception e)
        {
            throw new MetadataException("Can not read repository " + fileName, e);
        }
    }
1103941
@Override
    public MetaData parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException {
        Map<String, List<String>> metaData = MetaDataUtils.parseMetaData(parser);

        return new MetaData(metaData);
    }
498445
public final Source source(final Source source) {
    return new Source() {
      @Override public long read(Buffer sink, long byteCount) throws IOException {
        boolean throwOnTimeout = false;
        enter();
        try {
          long result = source.read(sink, byteCount);
          throwOnTimeout = true;
          return result;
        } catch (IOException e) {
          throw exit(e);
        } finally {
          exit(throwOnTimeout);
        }
      }

      @Override public void close() throws IOException {
        boolean throwOnTimeout = false;
        try {
          source.close();
          throwOnTimeout = true;
        } catch (IOException e) {
          throw exit(e);
        } finally {
          exit(throwOnTimeout);
        }
      }

      @Override public Timeout timeout() {
        return AsyncTimeout.this;
      }

      @Override public String toString() {
        return "AsyncTimeout.source(" + source + ")";
      }
    };
  }
809002
@Override
	public Map<String, Object> parseMap(InputStream source) {
		Map<String, Object> map = new LinkedHashMap<>();

		try (ParserWrapper parserWrapper = createParser(source)) {
			Map<String, Object> result = BindMapHelper.parseMap(this, parserWrapper, map);
			return result;
		} catch (Exception e) {
			e.printStackTrace();
			throw new KriptonRuntimeException(e);
		}
	}
1210155
private void parse(Annotation[] annotations) {
		Class<? extends Annotation> annotationType;
		for (Annotation annotation : annotations) {
			annotationType = annotation.annotationType();
			if (false == META_ANNOTATIONS.contains(annotationType)) {
				annotationMap.put(annotationType, annotation);
				parse(annotationType.getAnnotations());
			}
		}
	}
1086058
@Override
    public ResourceReference parse(String rawReference)
    {
        ResourceReference parsedResourceReference = null;

        // Step 1: Find the type parser matching the specified prefix type (if any).
        int pos = rawReference.indexOf(TYPE_SEPARATOR);
        if (pos > -1) {
            String typePrefix = rawReference.substring(0, pos);
            String reference = rawReference.substring(pos + 1);

            ComponentManager componentManager = this.componentManagerProvider.get();
            if (componentManager.hasComponent(ResourceReferenceTypeParser.class, typePrefix)) {
                try {
                    ResourceReferenceTypeParser parser =
                        componentManager.getInstance(ResourceReferenceTypeParser.class, typePrefix);
                    parsedResourceReference = parser.parse(reference);
                } catch (ComponentLookupException e) {
                    this.logger.error("Failed to initialize resource type parser", e);
                }
            }
        }

        // Step 2: If there's no specific type parser found, then consider it's an Unknown type.
        if (parsedResourceReference == null) {
            parsedResourceReference = new ResourceReference(rawReference, ResourceType.UNKNOWN);
        }

        // Step 3: If we're not in wiki mode then wiki references are considered URLs.
        if (!isInWikiMode() && WIKI_REFERENCE_TYPES.contains(parsedResourceReference.getType())) {
            parsedResourceReference = new ResourceReference(rawReference, ResourceType.URL);
            parsedResourceReference.setTyped(false);
        }

        return parsedResourceReference;
    }
274715
void parse(QEntityFactory entityFactory, EntityType<?> metadata, SessionFactoryImplementor sessionFactory)
	{
		this.metamodelEntity = metadata;
		this.name = metadata.getName();

		for (Attribute<?, ?> attribute : metadata.getAttributes())
		{
			parseFields(entityFactory, sessionFactory, null, attribute);
		}

		// Parse top-level properties

		// Add identifier property
		{
			if (!metadata.hasSingleIdAttribute())
				throw new IllegalArgumentException("@IdClass Entity not supported! " + metadata.getJavaType());

			Type idType = metadata.getIdType();

			switch (idType.getPersistenceType())
			{
				case BASIC:
					break; // No action necessary, will be processed like a normal field
				case EMBEDDABLE:
				{
					EmbeddableType<?> emb = (EmbeddableType<?>) idType;

					parseEmbeddable(entityFactory, sessionFactory, "id", emb);
					break;
				}
				default:
					throw new IllegalArgumentException("Cannot handle id type: " + idType.getPersistenceType() + ": " + idType);
			}
		}

		// Add links to descendants
		{
			final List<QEntity> descendants = entityFactory.getSubclasses(clazz);

			if (!descendants.isEmpty())
				this.descendants = descendants;
		}


		// Figure out the id method/field
		final String idPropertyName = getIdPropertyName();

		if (idPropertyName != null)
			this.idProperty = new PropertyWrapper(clazz, idPropertyName);
	}
1212382
SourceMetadata loadSourceMetadata(Class<?> clazz) {
        SourceMetadata metadata = metadataMap.get(clazz);
        if (metadata == null) {
            metadata = new SourceMetadata(clazz);
            SourceMetadata found = metadataMap.putIfAbsent(clazz, metadata);
            metadata = found == null ? metadata : found;
        }

        return metadata;
    }
568593
public synchronized Node parse(InputSource source) throws IOException, SAXException
    {
//        _dtd=null;
        Handler handler = new Handler();
        XMLReader reader = _parser.getXMLReader();
        reader.setContentHandler(handler);
        reader.setErrorHandler(handler);
        reader.setEntityResolver(handler);
        if (logger.isDebugEnabled())
            logger.debug("parsing: sid=" + source.getSystemId() + ",pid=" + source.getPublicId());
        _parser.parse(source, handler);
        if (handler.error != null)
            throw handler.error;
        Node root = (Node)handler.root;
        handler.reset();
        return root;
    }
1113410
public static <T> Set<T> wrapSet(final T... source) {
        val list = new LinkedHashSet<T>();
        addToCollection(list, source);
        return list;
    }
755819
public String parse(String source) {
        StringBuffer sbuf = new StringBuffer(source);
        Iterator key_it = argmap.keySet().iterator();

        //skipped = new RangeList();
        // What was this for??
        //process(source, "\"", "\""); // NOI18N
        while (key_it.hasNext()) {
            String it_key = (String) key_it.next();
            String it_obj = formatObject(argmap.get(it_key));
            int it_idx = -1;

            do {
                it_idx = sbuf.toString().indexOf(it_obj, ++it_idx);

                if (it_idx >= 0 /* && !skipped.containsOffset(it_idx) */) {
                    sbuf.replace(it_idx, it_idx + it_obj.length(), ldel + it_key + rdel);

                    //skipped = new RangeList();
                    // What was this for??
                    //process(sbuf.toString(), "\"", "\""); // NOI18N
                }
            } while (it_idx != -1);
        }

        return sbuf.toString();
    }
442966
private String computeTypeFromMappingSource(String source)
      throws MtasParserException {
    if (source.equals(MtasParserMapping.SOURCE_OWN)) {
      return null;
    } else if (source.equals(MtasParserMapping.SOURCE_ANCESTOR_GROUP)) {
      return MAPPING_TYPE_GROUP;
    } else if (source
        .equals(MtasParserMapping.SOURCE_ANCESTOR_GROUP_ANNOTATION)) {
      return MAPPING_TYPE_GROUP_ANNOTATION;
    } else if (source.equals(MtasParserMapping.SOURCE_ANCESTOR_WORD)) {
      return MAPPING_TYPE_WORD;
    } else if (source
        .equals(MtasParserMapping.SOURCE_ANCESTOR_WORD_ANNOTATION)) {
      return MAPPING_TYPE_WORD_ANNOTATION;
    } else if (source.equals(MtasParserMapping.SOURCE_ANCESTOR_RELATION)) {
      return MAPPING_TYPE_RELATION;
    } else if (source
        .equals(MtasParserMapping.SOURCE_ANCESTOR_RELATION_ANNOTATION)) {
      return MAPPING_TYPE_RELATION_ANNOTATION;
    } else {
      throw new MtasParserException("unknown source " + source);
    }
  }
1293697
public List<MetaDataResult> getMetaDataResultList() {
    JSONArray jsonArray = null;
    try {
      jsonArray = _jsonObject.getJSONArray(DATASETS_ARRAY_FIELD);
      List<MetaDataResult> metaDataResults = new ArrayList<MetaDataResult>(jsonArray.length());
      for (int i = 0; i < jsonArray.length(); i++) {
        metaDataResults.add(MetaDataResult.of(jsonArray.getJSONObject(i)));
      }
      return metaDataResults;
    } catch (JSONException ex) {
      s_logger.error("Metadata had unexpected structure - could not extract datasets field, was:\n{}", _jsonObject.toString());
      throw new QuandlRuntimeException("Metadata had unexpected structure", ex);
    }
  }
329967
public MediaQueryList parseMedia(final InputSource source) throws IOException {
        source_ = source;
        ReInit(getCharStream(source));
        final MediaQueryList ml = new MediaQueryList();
        try {
            mediaList(ml);
        }
        catch (final ParseException e) {
            getErrorHandler().error(toCSSParseException("invalidMediaList", e));
        }
        catch (final TokenMgrError e) {
            getErrorHandler().error(toCSSParseException(e));
        }
        catch (final CSSParseException e) {
            getErrorHandler().error(e);
        }
        return ml;
    }