| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| StringMacroAdapter |
|
| 1.0;1 |
| 1 | /* | |
| 2 | * Copyright (C) 1998-2000 Semiotek Inc. All Rights Reserved. | |
| 3 | * | |
| 4 | * Redistribution and use in source and binary forms, with or without | |
| 5 | * modification, are permitted under the terms of either of the following | |
| 6 | * Open Source licenses: | |
| 7 | * | |
| 8 | * The GNU General Public License, version 2, or any later version, as | |
| 9 | * published by the Free Software Foundation | |
| 10 | * (http://www.fsf.org/copyleft/gpl.html); | |
| 11 | * | |
| 12 | * or | |
| 13 | * | |
| 14 | * The Semiotek Public License (http://webmacro.org/LICENSE.) | |
| 15 | * | |
| 16 | * This software is provided "as is", with NO WARRANTY, not even the | |
| 17 | * implied warranties of fitness to purpose, or merchantability. You | |
| 18 | * assume all risks and liabilities associated with its use. | |
| 19 | * | |
| 20 | * See www.webmacro.org for more information on the WebMacro project. | |
| 21 | */ | |
| 22 | ||
| 23 | package org.webmacro.engine; | |
| 24 | ||
| 25 | import java.io.IOException; | |
| 26 | ||
| 27 | import org.webmacro.Context; | |
| 28 | import org.webmacro.FastWriter; | |
| 29 | import org.webmacro.Macro; | |
| 30 | import org.webmacro.TemplateVisitor; | |
| 31 | import org.webmacro.Visitable; | |
| 32 | ||
| 33 | /** | |
| 34 | * Looks like a Macro, but really it's a String. | |
| 35 | */ | |
| 36 | public final class StringMacroAdapter implements Macro, Visitable | |
| 37 | { | |
| 38 | ||
| 39 | final String _self; | |
| 40 | ||
| 41 | public StringMacroAdapter (String wrapMe) | |
| 42 | 0 | { |
| 43 | 0 | _self = wrapMe; |
| 44 | 0 | } |
| 45 | ||
| 46 | public final String toString () | |
| 47 | { | |
| 48 | 0 | return _self; |
| 49 | } | |
| 50 | ||
| 51 | public void accept (TemplateVisitor v) | |
| 52 | { | |
| 53 | 0 | v.visitString(toString()); |
| 54 | 0 | } |
| 55 | ||
| 56 | /** | |
| 57 | * Returns the wrapped object, context is ignored. | |
| 58 | */ | |
| 59 | public final Object evaluate (Context context) | |
| 60 | { | |
| 61 | 0 | return _self; |
| 62 | } | |
| 63 | ||
| 64 | /** | |
| 65 | * Just calls toString() and writes that, context is ignored. | |
| 66 | */ | |
| 67 | public final void write (FastWriter out, Context context) | |
| 68 | throws IOException | |
| 69 | { | |
| 70 | 0 | out.writeStatic(_self); |
| 71 | 0 | } |
| 72 | } |