当前位置: 首页>>代码示例>>Java>>正文


Java Try.get方法代码示例

本文整理汇总了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);

}
 
开发者ID:labra,项目名称:apiShaclex,代码行数:23,代码来源:SchemaCheckController.java

示例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);
}
 
开发者ID:labra,项目名称:apiShaclex,代码行数:14,代码来源:DataCheckController.java

示例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);
    }
}
 
开发者ID:labra,项目名称:apiShaclex,代码行数:38,代码来源:ValidateController.java

示例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());
    }
}
 
开发者ID:proglang,项目名称:jgs,代码行数:16,代码来源:RhsSwitch.java

示例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();
}
 
开发者ID:proglang,项目名称:jgs,代码行数:15,代码来源:ACasts.java

示例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();
}
 
开发者ID:proglang,项目名称:jgs,代码行数:16,代码来源:ACasts.java


注:本文中的scala.util.Try.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。