001/* 002 * JKNIV, SQLegance keeping queries maintainable. 003 * 004 * Copyright (C) 2017, the original author or authors. 005 * 006 * This library is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 2.1 of the License. 010 * 011 * This library is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public 017 * License along with this library; if not, write to the Free Software Foundation, Inc., 018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 019 */ 020package net.sf.jkniv.sqlegance.builder.xml.dynamic; 021 022import java.util.Collections; 023import java.util.List; 024 025/** 026 * This class represent text found at NodeValue from tag at XML document. Sample 027 * 028 * <pre> 029 * <update id="updateAuthor2" type="NATIVE"> 030 * update Author 031 * <set> 032 * <if test="username != null">username = #{username},</if> 033 * <if test="password != null">password = #{password},</if> 034 * <if test="email != null">email = #{email},</if> 035 * <if test="bio != null">bio = #{bio},</if> 036 * </set> 037 * where id=#{id} 038 * </update> 039 * </pre> 040 * 041 * Here we have two StaticText objects: 042 * 043 * <pre> 044 * update Author 045 * </pre> 046 * 047 * and 048 * 049 * <pre> 050 * where id=#{id} 051 * </pre> 052 * 053 * @author Alisson Gomes 054 */ 055public class StaticText implements ITextTag 056{ 057 private String text; 058 059 /** 060 * build static text object. 061 * 062 * @param text 063 * static 064 */ 065 public StaticText(String text) 066 { 067 this.text = text; 068 } 069 070 /** 071 * Evaluate if attribute test is true. 072 * 073 * @return always true, this is static text. 074 */ 075 public boolean eval(Object rootObjects) 076 { 077 return true; 078 } 079 080 /** 081 * Retrieve the text from XML element. 082 * 083 * @return text from XML element. 084 */ 085 public String getText() 086 { 087 return this.text; 088 } 089 090 public String getText(Object rootObjects) 091 { 092 return this.text; 093 } 094 095 /** 096 * Indicate if text is dynamic or static. 097 * 098 * @return always false is returned, because this object save static text. 099 */ 100 @Override 101 public boolean isDynamic() 102 { 103 return false; 104 } 105 106 @Override 107 public boolean isDynamicGroup() 108 { 109 return false; 110 } 111 112 @Override 113 public List<? extends ITextTag> getTags() 114 { 115 return Collections.emptyList(); 116 } 117 118}