|
|
@ -3,11 +3,12 @@ package com.fr.design.mainframe; |
|
|
|
import com.fr.base.io.BaseBook; |
|
|
|
import com.fr.base.io.BaseBook; |
|
|
|
import com.fr.file.FILE; |
|
|
|
import com.fr.file.FILE; |
|
|
|
import com.fr.stable.CoreConstants; |
|
|
|
import com.fr.stable.CoreConstants; |
|
|
|
import com.fr.third.javax.annotation.Nonnull; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.third.javax.annotation.Nullable; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import org.jetbrains.annotations.NotNull; |
|
|
|
|
|
|
|
import org.jetbrains.annotations.Nullable; |
|
|
|
|
|
|
|
|
|
|
|
public final class JTemplateFactory { |
|
|
|
public final class JTemplateFactory { |
|
|
|
private static final List<App<?>> ALL_APP = new ArrayList<App<?>>(); |
|
|
|
private static final List<App<?>> ALL_APP = new ArrayList<App<?>>(); |
|
|
@ -21,8 +22,7 @@ public final class JTemplateFactory { |
|
|
|
* @param file 包含了模板名称,类型以及内容的文件 |
|
|
|
* @param file 包含了模板名称,类型以及内容的文件 |
|
|
|
* @return 设计器编辑的模板对象 |
|
|
|
* @return 设计器编辑的模板对象 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Nullable |
|
|
|
public static JTemplate<?, ?> createJTemplate(@NotNull FILE file) { |
|
|
|
public static JTemplate<?, ?> createJTemplate(@Nonnull FILE file) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String fileName = file.getName(); |
|
|
|
String fileName = file.getName(); |
|
|
|
int indexOfLastDot = fileName.lastIndexOf(CoreConstants.DOT); |
|
|
|
int indexOfLastDot = fileName.lastIndexOf(CoreConstants.DOT); |
|
|
@ -44,14 +44,18 @@ public final class JTemplateFactory { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static <T extends BaseBook> T asIOFile(@Nonnull FILE file) { |
|
|
|
@Nullable |
|
|
|
|
|
|
|
public static <T extends BaseBook> T asIOFile(@NotNull FILE file, String fileNameOrSuffix) { |
|
|
|
|
|
|
|
|
|
|
|
String fileName = file.getName(); |
|
|
|
if (StringUtils.isEmpty(fileNameOrSuffix)) { |
|
|
|
int indexOfLastDot = fileName.lastIndexOf(CoreConstants.DOT); |
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int indexOfLastDot = fileNameOrSuffix.lastIndexOf(CoreConstants.DOT); |
|
|
|
if (indexOfLastDot < 0) { |
|
|
|
if (indexOfLastDot < 0) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
String fileExtension = fileName.substring(indexOfLastDot + 1); |
|
|
|
String fileExtension = fileNameOrSuffix.substring(indexOfLastDot + 1); |
|
|
|
for (App<?> app : ALL_APP) { |
|
|
|
for (App<?> app : ALL_APP) { |
|
|
|
String[] defaultAppExtensions = app.defaultExtensions(); |
|
|
|
String[] defaultAppExtensions = app.defaultExtensions(); |
|
|
|
for (String defaultAppExtension : defaultAppExtensions) { |
|
|
|
for (String defaultAppExtension : defaultAppExtensions) { |
|
|
@ -66,6 +70,12 @@ public final class JTemplateFactory { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Nullable |
|
|
|
|
|
|
|
public static <T extends BaseBook> T asIOFile(@NotNull FILE file) { |
|
|
|
|
|
|
|
return asIOFile(file, file.getName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 注册app. |
|
|
|
* 注册app. |
|
|
|