当前位置: 首页 > news >正文

博山区住房和城乡建设局网站网络推广的渠道

博山区住房和城乡建设局网站,网络推广的渠道,外贸网站增加权重,网站备案需要具备什么条件文章目录 一、解释器模式定义二、例子2.1 菜鸟教程例子2.1.1 定义一个表达式接口2.1.2 实现Expression接口2.1.3 定义解析规则2.1.4 使用 2.2 JDK源码——Pattern2.3 Spring源码——ExpressionParser 三、其他设计模式 一、解释器模式定义 类型#xff1a; 行为型模式 目的 行为型模式 目的 实现了一个表达式接口该接口解释一个特定的上下文。这种模式被用在 SQL 解析、符号处理引擎等 二、例子 2.1 菜鸟教程例子 2.1.1 定义一个表达式接口 public interface Expression {public boolean interpret(String context); } 2.1.2 实现Expression接口 public class TerminalExpression implements Expression {private String data;public TerminalExpression(String data){this.data data; }Overridepublic boolean interpret(String context) {if(context.contains(data)){return true;}return false;} }public class OrExpression implements Expression {private Expression expr1 null;private Expression expr2 null;public OrExpression(Expression expr1, Expression expr2) { this.expr1 expr1;this.expr2 expr2;}Overridepublic boolean interpret(String context) { return expr1.interpret(context) || expr2.interpret(context);} }public class AndExpression implements Expression {private Expression expr1 null;private Expression expr2 null;public AndExpression(Expression expr1, Expression expr2) { this.expr1 expr1;this.expr2 expr2;}Overridepublic boolean interpret(String context) { return expr1.interpret(context) expr2.interpret(context);} }2.1.3 定义解析规则 public class Expressions {//规则Robert 和 John 是男性public static Expression getMaleExpression(){Expression robert new TerminalExpression(Robert);Expression john new TerminalExpression(John);return new OrExpression(robert, john); }//规则Julie 是一个已婚的女性public static Expression getMarriedWomanExpression(){Expression julie new TerminalExpression(Julie);Expression married new TerminalExpression(Married);return new AndExpression(julie, married); } }2.1.4 使用 public class InterpreterPatternDemo {public static void main(String[] args) {Expression isMale Expressions.getMaleExpression();System.out.println(John is male? isMale.interpret(John));Expression isMarriedWoman Expressions.getMarriedWomanExpression();System.out.println(Julie is a married women? isMarriedWoman.interpret(Married Julie));} }2.2 JDK源码——Pattern public final class Pattern implements java.io.Serializable {public static Pattern compile(String regex) {return new Pattern(regex, 0);}public static Pattern compile(String regex, int flags) {return new Pattern(regex, flags);}private String pattern;public String pattern() {return pattern;}private Pattern(String p, int f) {if ((f ~ALL_FLAGS) ! 0) {throw new IllegalArgumentException(Unknown flag 0x Integer.toHexString(f));}pattern p;flags f;// to use UNICODE_CASE if UNICODE_CHARACTER_CLASS presentif ((flags UNICODE_CHARACTER_CLASS) ! 0)flags | UNICODE_CASE;// flags for compilingflags0 flags;// Reset group index countcapturingGroupCount 1;localCount 0;localTCNCount 0;if (!pattern.isEmpty()) {try {compile();} catch (StackOverflowError soe) {throw error(Stack overflow during pattern compilation);}} else {root new Start(lastAccept);matchRoot lastAccept;}} private void compile() {.....} }static class Start extends Node {int minLength;Start(Node node) {this.next node;TreeInfo info new TreeInfo();next.study(info);minLength info.minLength;}...... }static final class StartS extends Start {StartS(Node node) {super(node);} }static final class Begin extends Node {boolean match(Matcher matcher, int i, CharSequence seq) {.......} }static final class End extends Node {boolean match(Matcher matcher, int i, CharSequence seq) {...} }2.3 Spring源码——ExpressionParser public interface ExpressionParser {Expression parseExpression(String expressionString) throws ParseException;Expression parseExpression(String expressionString, ParserContext context) throws ParseException; } public class SpelExpressionParser extends TemplateAwareExpressionParser {private final SpelParserConfiguration configuration;public SpelExpressionParser() {this.configuration new SpelParserConfiguration();}public SpelExpressionParser(SpelParserConfiguration configuration) {Assert.notNull(configuration, SpelParserConfiguration must not be null);this.configuration configuration;}public SpelExpression parseRaw(String expressionString) throws ParseException {Assert.hasText(expressionString, expressionString must not be null or blank);return this.doParseExpression(expressionString, (ParserContext)null);}protected SpelExpression doParseExpression(String expressionString, Nullable ParserContext context) throws ParseException {return (new InternalSpelExpressionParser(this.configuration)).doParseExpression(expressionString, context);} } class InternalSpelExpressionParser extends TemplateAwareExpressionParser {private final DequeSpelNodeImpl constructedNodes new ArrayDeque();protected SpelExpression doParseExpression(String expressionString, Nullable ParserContext context) throws ParseException {this.checkExpressionLength(expressionString);try {this.expressionString expressionString;Tokenizer tokenizer new Tokenizer(expressionString);this.tokenStream tokenizer.process();this.tokenStreamLength this.tokenStream.size();this.tokenStreamPointer 0;this.constructedNodes.clear();SpelNodeImpl ast this.eatExpression();if (ast null) {throw new SpelParseException(this.expressionString, 0, SpelMessage.OOD, new Object[0]);} else {Token t this.peekToken();if (t ! null) {throw new SpelParseException(this.expressionString, t.startPos, SpelMessage.MORE_INPUT, new Object[]{this.toString(this.nextToken())});} else {return new SpelExpression(expressionString, ast, this.configuration);}}} catch (InternalParseException var6) {throw var6.getCause();}}}三、其他设计模式 创建型模式 结构型模式 1、设计模式——装饰器模式Decorator Pattern Spring相关源码 行为型模式 1、设计模式——访问者模式Visitor Pattern Spring相关源码2、设计模式——中介者模式Mediator Pattern JDK相关源码3、设计模式——策略模式Strategy Pattern Spring相关源码4、设计模式——状态模式State Pattern5、设计模式——命令模式Command Pattern Spring相关源码6、设计模式——观察者模式Observer Pattern Spring相关源码7、设计模式——备忘录模式Memento Pattern8、设计模式——模板方法模式Template Pattern Spring相关源码9、设计模式——迭代器模式Iterator Pattern Spring相关源码10、设计模式——责任链模式Chain of Responsibility Pattern Spring相关源码11、设计模式——解释器模式Interpreter Pattern Spring相关源码
http://www.pierceye.com/news/37272/

相关文章:

  • 禹州市城乡建设局网站做查询新生寝室的网站
  • 建设通网站查询单位淘宝店铺怎么买
  • 网站建设与设计试题电子产品开发流程图
  • 做网站切图优化加速
  • 怎样批量做地级市网站教育海报设计素材网站
  • 阿里巴巴跟建设网站的区别北京网站建设手机号
  • app产品开发流程seo 培训教程
  • 广州网站建设+致茂自动生成网页的工具
  • 深圳定做网站青岛百度seo
  • 建网站的英文客户关系管理流程图
  • 餐饮加盟网网站建设网站开发技术教材
  • 南昌专业网站优化推广企业管理咨询公司排行
  • 哪些公司需要网站建设江西省住房城乡建设厅网站
  • 成都神速建站建设一个网站要多少费用
  • 福建工程网站建设团队建德做网站
  • 网站建设需求 百度文库许昌做网站优化
  • 盐城网站建设服务php商城
  • jsp网站开发的环境配置网站标题logo怎么做的
  • 台州专业网站建设方案建设通属于官方网站
  • 江海区建设局网站网站的pv是什么
  • 课题组网站怎么做霸州做网站shijuewang
  • 做照片模板下载网站wordpress迁移后地址没变
  • 网站开发怎么入账做的网站如何发布会
  • 微信手机网站搭建广东免费网络推广软件
  • 东莞网站建设市场分析坑梓做网站公司怎么样
  • 如何做网站推广私人如何设置网站标题
  • 网站建设提议网站建设实训进程计划
  • 西安双语网站建设长沙网站建设公司招聘
  • 泉州网站建设-泉州网站建设公司做神马网站优
  • 江苏建设人才网网站网站建设有什么技术