本文整理汇总了Java中scala.util.Try.get方法的典型用法代码示例。如果您正苦于以下问题:Java Try.get方法的具体用法?Java Try.get怎么用?Java Try.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scala.util.Try
的用法示例。
在下文中一共展示了Try.get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: schemaCheck
import scala.util.Try; //导入方法依赖的package包/类
@RequestMapping(SCHEMA_CHECK_URI)
public SchemaCheckResult schemaCheck(@RequestParam(value="schema") String schema,
@RequestParam(value="schemaFormat") String schemaFormat,
@RequestParam(value="schemaEngine") String schemaEngine,
@RequestParam(value="resultFormat") String resultFormat) {
Option<String> base = Option.apply(null);
Try<Schema> t = Schemas.fromString(schema,schemaFormat, schemaEngine, base);
if (t.isSuccess()) {
Schema s = t.get();
Try<String> tstr = s.serialize(resultFormat);
if (tstr.isSuccess()) {
return new SchemaCheckResult(schema,schemaFormat,resultFormat,tstr.get());
} else {
return new SchemaCheckResult(schema,schemaFormat,resultFormat,
"Error: " + tstr);
}
} else
return new SchemaCheckResult(schema,schemaFormat,resultFormat,
"Error: " + t);
}
示例2: dataCheck
import scala.util.Try; //导入方法依赖的package包/类
@RequestMapping(DATA_CHECK_URI)
public DataCheckResult dataCheck(@RequestParam(value="data") String data,
@RequestParam(value="dataFormat") String dataFormat,
@RequestParam(value="resultFormat") String resultFormat) {
Option<String> base = Option.apply(null);
Try<RDFAsJenaModel> t = RDFAsJenaModel.fromChars(data,dataFormat, base);
if (t.isSuccess()) {
RDFReader s = t.get();
String tstr = s.serialize(resultFormat);
return new DataCheckResult(data,dataFormat,resultFormat,tstr);
} else
return new DataCheckResult(data,dataFormat,resultFormat,"Error: " + t);
}
示例3: validate
import scala.util.Try; //导入方法依赖的package包/类
@RequestMapping(VALIDATE_URI)
public ValidateResult validate(
@RequestParam(value="schema") String schema,
@RequestParam(value="schemaFormat") String schemaFormat,
@RequestParam(value="schemaEngine") String schemaEngine,
@RequestParam(value="data") String data,
@RequestParam(value="dataFormat") String dataFormat,
@RequestParam(value="resultFormat") String resultFormat) {
Option<String> base = Option.apply(null);
List<String> emptyErrors = new ArrayList<String>();
Try<Schema> t = Schemas.fromString(schema,schemaFormat, schemaEngine, base);
if (t.isSuccess()) {
Schema s = t.get();
Try<String> tstr = s.serialize(resultFormat);
if (tstr.isSuccess()) {
Try<RDFAsJenaModel> trdf = RDFAsJenaModel.fromChars(data,dataFormat,base);
if (trdf.isSuccess()) {
Result r = s.validate(trdf.get());
String strResult = r.serialize(resultFormat);
// TODO: Populate errors and solutions...
new ValidateResult(schema,schemaFormat,schemaEngine,data,dataFormat,emptyErrors,r.isValid(),
strResult, resultFormat);
} else
new ValidateResult(schema,schemaFormat,schemaEngine,data,dataFormat,emptyErrors,false,
"Error: " + trdf, resultFormat);
return new ValidateResult(schema,schemaFormat,schemaEngine,data,dataFormat,emptyErrors,false,
"Error: " + t,resultFormat);
} else {
return new ValidateResult(schema,schemaFormat,schemaEngine,data,dataFormat,emptyErrors,false,
"Error: " + tstr,resultFormat);
}
} else {
return new ValidateResult(schema,schemaFormat,schemaEngine,data,dataFormat,emptyErrors,false,
"Error: " + t,resultFormat);
}
}
示例4: caseStaticInvokeExpr
import scala.util.Try; //导入方法依赖的package包/类
@Override
public void caseStaticInvokeExpr(StaticInvokeExpr v) {
Try<Option<ValueCast<Level>>> tc = casts.detectValueCastFromCall(v);
if (tc.isSuccess()) {
Option<ValueCast<Level>> c = tc.get();
if (c.isDefined()) {
caseCast(c.get());
} else {
caseCall(v, Option.<Value>empty());
}
} else {
caseFail(tc.failed().get());
}
}
示例5: detectValueCastFromStmt
import scala.util.Try; //导入方法依赖的package包/类
public Option<ValueCast<Level>> detectValueCastFromStmt(Stmt s) throws TypingException {
if (s.containsInvokeExpr()) {
InvokeExpr e = s.getInvokeExpr();
if (e instanceof StaticInvokeExpr) {
Try<Option<ValueCast<Level>>> result = this.detectValueCastFromCall((StaticInvokeExpr) e);
if (result.isSuccess()) {
return result.get();
} else {
throw new TypingException(result.failed().get().getMessage());
}
}
}
return Option.empty();
}
示例6: detectContextCastStartFromStmt
import scala.util.Try; //导入方法依赖的package包/类
public Option<CxCast<Level>> detectContextCastStartFromStmt(Stmt s)
throws TypingException {
if (s.containsInvokeExpr()) {
InvokeExpr e = s.getInvokeExpr();
if (e instanceof StaticInvokeExpr) {
Try<Option<CxCast<Level>>> result = this.detectContextCastStartFromCall((StaticInvokeExpr) e);
if (result.isSuccess()) {
return result.get();
} else {
throw new TypingException(result.failed().get().getMessage());
}
}
}
return Option.empty();
}