All Downloads are FREE. Search and download functionalities are using the official Maven repository.

br.com.objectos.fs.LocalFsJava6 Maven / Gradle / Ivy

/*
 * Copyright (C) 2021-2022 Objectos Software LTDA.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package br.com.objectos.fs;

import br.com.objectos.core.object.Checks;
import br.com.objectos.latest.Concrete.Bridge;
import java.io.File;
import java.net.URI;

@Bridge
class LocalFsJava6 extends LocalFsJavaAny {

  @Override
  final ObjectJavaAny create(File file) {
    Checks.checkNotNull(file, "file == null");

    return new ObjectImpl(file);
  }

  @Override
  final ObjectJavaAny create(String first, String... more) {
    File file;
    file = getFile(first, more);

    return new ObjectImpl(file);
  }

  @Override
  final ObjectJavaAny create(URI uri) {
    Checks.checkNotNull(uri, "uri == null");

    File file;
    file = new File(uri);

    return new ObjectImpl(file);
  }

  private File getFile(String first, String[] more) {
    Checks.checkNotNull(first, "first == null");
    Checks.checkNotNull(more, "more == null");

    StringBuilder s;
    s = new StringBuilder(first);

    for (int i = 0; i < more.length; i++) {
      s.append(File.separatorChar);

      String part;
      part = more[i];

      s.append(
          Checks.checkNotNull(part, "more[", i, "] == null")
      );
    }

    String result;
    result = s.toString();

    return new File(result);
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy