Package com.aaspring.util.file

Examples of com.aaspring.util.file.FileAccessorProperties


      final BundleProps bundleProps, final FileAccessor fileAccessor) {
    this.bundleProps = bundleProps;
    this.parent = parent;
    InputStream is = null;
    try {
      FileAccessorProperties fap = bundleProps
          .getFileAccessorProperties();
      is = fileAccessor.getInputStream(fap.getType(),
          fap.getAttributes(), fap.getLocale());
      if (is != null)
        lookup.load(is);
    } catch (IOException e) {
      // No problem, the file does not exists
    } finally {
View Full Code Here


  }

  public TextBundleImpl(final TextBundleImpl parent,
      final BundleProps bundleProps, final FileAccessor fileAccessor) {
    this.bundleProps = bundleProps;
    FileAccessorProperties fap = bundleProps.getFileAccessorProperties();
    String encoding = fap.getAttributes().get("encoding");
    if (encoding == null)
      encoding = "UTF8";
    this.parent = parent;
    BufferedReader reader = null;
    try {
      InputStream is = fileAccessor.getInputStream(fap.getType(), fap
          .getAttributes(), fap.getLocale());
      if (is != null) {
        reader = new BufferedReader(new InputStreamReader(is, encoding));
        StringBuilder sb = new StringBuilder();
        String line = reader.readLine();
        boolean firstRow = true;
View Full Code Here

    } else if (!"".equals(locale.getLanguage())) {
      parentLocale = new Locale("");
    }
    TextBundleImpl parent = null;
    if (parentLocale != null) {
      FileAccessorProperties fap = props.getFileAccessorProperties();
      BundleProps parentpbp = new BundleProps(new FileAccessorProperties(
          fap.getAttributes(), fap.getType(), parentLocale));
      parent = (TextBundleImpl) BundleFactory.getBundle(parentpbp,
          "text", fileAccessor);
    }

    return new TextBundleImpl(parent, props, fileAccessor);
View Full Code Here

    } else if (!"".equals(locale.getLanguage())) {
      parentLocale = new Locale("");
    }
    PropertiesBundleImpl parent = null;
    if (parentLocale != null) {
      FileAccessorProperties fap = props.getFileAccessorProperties();
      BundleProps parentpbp = new BundleProps(new FileAccessorProperties(
          fap.getAttributes(), fap.getType(), parentLocale));
      parent = (PropertiesBundleImpl) BundleFactory.getBundle(parentpbp,
          "properties", fileAccessor);
    }

    return new PropertiesBundleImpl(parent, props, fileAccessor);
View Full Code Here

      Map<String, String> propsOfPath = getPropertiesOfPath(path,
          basePaths.get(basePathId));
      for (Locale locale : locales) {
        for (Locale currentLocale : getLocaleWithParents(locale)) {
          try {
            fac.addFile(new FileAccessorProperties(propsOfPath,
                path.getType(), currentLocale));
          } catch (InvalidStateException e) {
            throw new RuntimeException("Should never happen", e);
          }
        }
      }
    }

    for (LanguageFile lf : ls.getLanguageFiles().getLanguageFile()) {
      Path path = lf.getPath();
      String basePathId = path.getBasePathId();
      Map<String, String> propsOfPath = getPropertiesOfPath(path,
          basePaths.get(basePathId));
      List<Bundle> bundles = new ArrayList<Bundle>(locales.length);
      for (Locale locale : locales) {
        bundles.add(BundleFactory.getBundle(new BundleProps(
            new FileAccessorProperties(propsOfPath, path.getType(),
                locale)), lf.getType().value(), fac));
      }
      Enumeration<String> keys = bundles.get(0).getKeys();
      while (keys.hasMoreElements()) {
        String key = keys.nextElement();
View Full Code Here

      String basePathId = path.getBasePathId();
      Map<String, String> propsOfPath = getPropertiesOfPath(path,
          basePaths.get(basePathId));
      for (Locale targetLocale : localeMapping.values()) {
        try {
          fac.addFile(new FileAccessorProperties(propsOfPath, path
              .getType(), targetLocale));
        } catch (InvalidStateException e) {
          // Should never happen
          e.printStackTrace();
        }
      }
    }

    Map<FileAccessorProperties, OutputStream> outStreamMap = fac
        .getOutputStreams();
    for (String field : fieldKeyLocaleValueMap.keySet()) {
      LanguageFile lf = lfById.get(field);
      Path path = lf.getPath();
      String basePathId = path.getBasePathId();
      Map<String, String> propsOfPath = getPropertiesOfPath(path,
          basePaths.get(basePathId));
      Map<Locale, Map<String, String>> localeKeyValueMap = fieldKeyLocaleValueMap
          .get(field);
      for (Locale sourceLocale : localeMapping.keySet()) {
        Map<String, String> keyValueMap = localeKeyValueMap
            .get(sourceLocale);
        FileAccessorProperties fap = new FileAccessorProperties(
            propsOfPath, path.getType(), localeMapping
                .get(sourceLocale));

        Bundle bundle = BundleFactory.createEmptyBundle(
            new BundleProps(fap), lf.getType().value());
View Full Code Here

TOP

Related Classes of com.aaspring.util.file.FileAccessorProperties

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.