/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you 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 org.apache.shindig.gadgets.features;

import org.apache.shindig.common.util.ResourceLoader;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;

/**
 * DefaultFile delegate feature file interface to java.io.File object
 */
public class DefaultFeatureFile implements FeatureFile {

  private final File wrappedFile;

  public DefaultFeatureFile(String path) {
    this.wrappedFile = new File(path);
  }

  private DefaultFeatureFile(File wrappedFile) {
    this.wrappedFile = wrappedFile;
  }
  public InputStream getInputStream() throws IOException {
    return new FileInputStream(wrappedFile);
  }

  public boolean canRead() {
    return wrappedFile.canRead();
  }

  public boolean exists() {
    return wrappedFile.exists();
  }

  public String getName() {
    return wrappedFile.getName();
  }

  public String getPath() {
    return wrappedFile.getPath();
  }

  public String getAbsolutePath() {
    return wrappedFile.getAbsolutePath();
  }

  public boolean isDirectory() {
    return wrappedFile.isDirectory();
  }

  public FeatureFile[] listFiles() {
    File[] wrappedFiles = wrappedFile.listFiles();
    FeatureFile[] files = new FeatureFile[wrappedFiles.length];
    for (int i = 0; i < wrappedFiles.length; i++) {
      files[i] = new DefaultFeatureFile(wrappedFiles[i]);
    }
    return files;
  }

  public URI toURI() {
    return wrappedFile.toURI();
  }

  public String getContent() throws IOException {
    return ResourceLoader.getContent(wrappedFile);
  }

  public long lastModified() {
    return wrappedFile.lastModified();
  }
}

@@ -1168,21 +1168,23 @@
  %7B%0A%0A  pr
-ivate
+otected
  final F
@@ -1296,13 +1296,15 @@
   pr
-ivate
+otected
  Def
@@ -1379,16 +1379,132 @@
 le;%0A  %7D%0A
+%0A  protected DefaultFeatureFile createFile(File wrappedFile) %7B%0A    return new DefaultFeatureFile(wrappedFile);%0A  %7D%0A%0A
   public
@@ -2119,16 +2119,73 @@
 iles();%0A
+    if (wrappedFiles == null) %7B%0A      return null;%0A    %7D%0A
     Feat
@@ -2309,33 +2309,21 @@
 es%5Bi%5D = 
-new DefaultF
+cr
 eat
-ur
 eFile(wr

Update DefaultFeatureFile to allow easy override of listFiles | http://codereview.appspot.com/4438098/