开发者

Setting the value to list

I am facing a issue in setting the value to the list of SoyFileSupplier,the list should have a value of type file,the soyfilesetParse class is used for parsing by passing a soyFileSupplier list,setting the value to a file.(sample.soy)

The sample code is as below:

public class test {
     main() {
          soyTree=parseSoyFiles(soyFileSuppliers);
     }
}

The calling class is :

public class soyFileSetParse {
    public static SoyFileSetNode parseSoyFiles(List<SoyFileSupplier> soyFileSuppliers)
        throws SoySyntaxException {

        IdGenerator nodeIdGen = new IntegerIdGenerator();
        SoyFileSetNode soyTree = new SoyFileSetNo开发者_如何学Gode(nodeIdGen.genStringId(), nodeIdGen);

        for (SoyFileSupplier soyFileSupplier : soyFileSuppliers) {
            soyTree.addChild(parseSoyFileHelper(soyFileSupplier, nodeIdGen));
        }

        return soyTree;
    }
}

Setting to file type :

public class SoyFileSupplier {
  /**
   * Creates a new {@code SoyFileSupplier} given a {@code File}.
   *
   * @param inputFile The Soy file.
   */
  public SoyFileSupplier(File inputFile) {
      this(Files.newReaderSupplier(inputFile, Charsets.UTF_8), inputFile.getPath());
  }

I am not getting what i am doing wrong.


Since parseSoyFiles(...) is a static method of the soyFileSetParse class, you'll need to invoke it with the class name, without the need for creating an instance of the class, as in

ClassName.methodName(args)

Therefore, the content of your main() method should look as follows

SoyFileSetNode soyTree = soyFileSetParse.parseSoyFiles(soyFileSuppliers);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜