Package com.google.i18n.phonenumbers.Phonemetadata

Examples of com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadataCollection


      throw new IllegalStateException("missing metadata: " + fileName);
    }
    ObjectInputStream in = null;
    try {
      in = new ObjectInputStream(source);
      PhoneMetadataCollection metadataCollection = loadMetadataAndCloseInput(in);
      List<PhoneMetadata> metadataList = metadataCollection.getMetadataList();
      if (metadataList.isEmpty()) {
        logger.log(Level.SEVERE, "empty metadata: " + fileName);
        throw new IllegalStateException("empty metadata: " + fileName);
      }
      if (metadataList.size() > 1) {
View Full Code Here


   *
   * @param source  the non-null stream from which metadata is to be read.
   * @return        the loaded metadata protocol buffer.
   */
  private static PhoneMetadataCollection loadMetadataAndCloseInput(ObjectInputStream source) {
    PhoneMetadataCollection metadataCollection = new PhoneMetadataCollection();
    try {
      metadataCollection.readExternal(source);
    } catch (IOException e) {
      logger.log(Level.WARNING, "error reading input (ignored)", e);
    } finally {
      try {
        source.close();
View Full Code Here

    String inputFile = args[1];
    String outputFile = args[2];
    boolean liteBuild = args.length > 3 && args[3].equals("true");

    try {
      PhoneMetadataCollection metadataCollection =
          BuildMetadataFromXml.buildPhoneMetadataCollection(inputFile, liteBuild);
      Map<Integer, List<String>> countryCodeToRegionCodeMap =
          BuildMetadataFromXml.buildCountryCodeToRegionCodeMap(metadataCollection);

      BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile));
View Full Code Here

    InputStream source = PhoneNumberMatcher.class.getResourceAsStream(
        ALTERNATE_FORMATS_FILE_PREFIX + "_" + countryCallingCode);
    ObjectInputStream in = null;
    try {
      in = new ObjectInputStream(source);
      PhoneMetadataCollection alternateFormats = new PhoneMetadataCollection();
      alternateFormats.readExternal(in);
      for (PhoneMetadata metadata : alternateFormats.getMetadataList()) {
        callingCodeToAlternateFormatsMap.put(metadata.getCountryCode(), metadata);
      }
    } catch (IOException e) {
      LOGGER.log(Level.WARNING, e.toString());
    } finally {
View Full Code Here

    InputStream source = PhoneNumberMatcher.class.getResourceAsStream(
        SHORT_NUMBER_METADATA_FILE_PREFIX + "_" + regionCode);
    ObjectInputStream in = null;
    try {
      in = new ObjectInputStream(source);
      PhoneMetadataCollection shortNumberMetadata = new PhoneMetadataCollection();
      shortNumberMetadata.readExternal(in);
      for (PhoneMetadata metadata : shortNumberMetadata.getMetadataList()) {
        regionCodeToShortNumberMetadataMap.put(regionCode, metadata);
      }
    } catch (IOException e) {
      LOGGER.log(Level.WARNING, e.toString());
    } finally {
View Full Code Here

    }

    String filePrefix = new File(outputDir, dataPrefix).getPath();

    try {
      PhoneMetadataCollection metadataCollection =
          BuildMetadataFromXml.buildPhoneMetadataCollection(inputFile, liteBuild);

      for (PhoneMetadata metadata : metadataCollection.getMetadataList()) {
        String regionCode = metadata.getId();
        // For non-geographical country calling codes (e.g. +800), or for alternate formats, use the
        // country calling codes instead of the region code to form the file name.
        if (regionCode.equals("001") || regionCode.isEmpty()) {
          regionCode = Integer.toString(metadata.getCountryCode());
        }
        PhoneMetadataCollection outMetadataCollection = new PhoneMetadataCollection();
        outMetadataCollection.addMetadata(metadata);
        FileOutputStream outputForRegion = new FileOutputStream(filePrefix + "_" + regionCode);
        ObjectOutputStream out = new ObjectOutputStream(outputForRegion);
        outMetadataCollection.writeExternal(out);
        out.close();
      }

      Map<Integer, List<String>> countryCodeToRegionCodeMap =
          BuildMetadataFromXml.buildCountryCodeToRegionCodeMap(metadataCollection);
View Full Code Here

    }

    String filePrefix = new File(outputDir, dataPrefix).getPath();

    try {
      PhoneMetadataCollection metadataCollection =
          BuildMetadataFromXml.buildPhoneMetadataCollection(inputFile, liteBuild);

      for (PhoneMetadata metadata : metadataCollection.getMetadataList()) {
        String regionCode = metadata.getId();
        // For non-geographical country calling codes (e.g. +800), or for alternate formats, use the
        // country calling codes instead of the region code to form the file name.
        if (regionCode.equals("001") || regionCode.isEmpty()) {
          regionCode = Integer.toString(metadata.getCountryCode());
        }
        PhoneMetadataCollection outMetadataCollection = new PhoneMetadataCollection();
        outMetadataCollection.addMetadata(metadata);
        FileOutputStream outputForRegion = new FileOutputStream(filePrefix + "_" + regionCode);
        ObjectOutputStream out = new ObjectOutputStream(outputForRegion);
        outMetadataCollection.writeExternal(out);
        out.close();
      }

      Map<Integer, List<String>> countryCodeToRegionCodeMap =
          BuildMetadataFromXml.buildCountryCodeToRegionCodeMap(metadataCollection);
View Full Code Here

    String inputFile = args[1];
    String outputFile = args[2];
    boolean liteBuild = args.length > 3 && args[3].equals("true");

    try {
      PhoneMetadataCollection metadataCollection =
          BuildMetadataFromXml.buildPhoneMetadataCollection(inputFile, liteBuild);
      Map<Integer, List<String>> countryCodeToRegionCodeMap =
          BuildMetadataFromXml.buildCountryCodeToRegionCodeMap(metadataCollection);

      BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile));
View Full Code Here

    InputStream source = PhoneNumberMatcher.class.getResourceAsStream(
        ALTERNATE_FORMATS_FILE_PREFIX + "_" + countryCallingCode);
    ObjectInputStream in = null;
    try {
      in = new ObjectInputStream(source);
      PhoneMetadataCollection alternateFormats = new PhoneMetadataCollection();
      alternateFormats.readExternal(in);
      for (PhoneMetadata metadata : alternateFormats.getMetadataList()) {
        callingCodeToAlternateFormatsMap.put(metadata.getCountryCode(), metadata);
      }
    } catch (IOException e) {
      LOGGER.log(Level.WARNING, e.toString());
    } finally {
View Full Code Here

        ? PhoneNumberUtil.class.getResourceAsStream(filePrefix + "_" + countryCallingCode)
        : PhoneNumberUtil.class.getResourceAsStream(filePrefix + "_" + regionCode);
    ObjectInputStream in = null;
    try {
      in = new ObjectInputStream(source);
      PhoneMetadataCollection metadataCollection = new PhoneMetadataCollection();
      metadataCollection.readExternal(in);
      for (PhoneMetadata metadata : metadataCollection.getMetadataList()) {
        if (isNonGeoRegion) {
          countryCodeToNonGeographicalMetadataMap.put(countryCallingCode, metadata);
        } else {
          regionToMetadataMap.put(regionCode, metadata);
        }
View Full Code Here

TOP

Related Classes of com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadataCollection

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.