我在将值设置为SoyFileSupplier列表时遇到问题,列表应该具有type file的值,soyfilesetParse类用于通过传递soyFileSupplier列表进行解析,将值设置为文件。 .soy)
The sample code is as below:
public class test {
main() {
soyTree=parseSoyFiles(soyFileSuppliers);
}
}
调用类是:
public class soyFileSetParse {
public static SoyFileSetNode parseSoyFiles(List<SoyFileSupplier> soyFileSuppliers)
throws SoySyntaxException {
IdGenerator nodeIdGen = new IntegerIdGenerator();
SoyFileSetNode soyTree = new SoyFileSetNode(nodeIdGen.genStringId(), nodeIdGen);
for (SoyFileSupplier soyFileSupplier : soyFileSuppliers) {
soyTree.addChild(parseSoyFileHelper(soyFileSupplier, nodeIdGen));
}
return soyTree;
}
}
设置为文件类型:
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());
}
我没有得到我做错的事。
答案 0 :(得分:1)
由于parseSoyFiles(...)
是static
类的soyFileSetParse
方法,因此您需要使用类名调用它,而无需创建类的实例,如在
ClassName.methodName(args)
因此,main()
方法的内容应如下所示
SoyFileSetNode soyTree = soyFileSetParse.parseSoyFiles(soyFileSuppliers);