blob: abc470c6bfa8e559ac3af313f52ea9bd822b01d4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/*******************************************************************************
* Copyright (c) 2013 Tasktop Technologies and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* David Green - initial API and implementation
*******************************************************************************/
package org.eclipse.mylyn.wikitext.parser.builder.event;
import static com.google.common.base.Preconditions.checkNotNull;
import org.eclipse.mylyn.wikitext.parser.DocumentBuilder;
import com.google.common.base.Objects;
/**
* An {@link DocumentBuilderEvent} corresponding to {@link DocumentBuilder#characters(String)}.
*
* @author david.green
* @since 3.0
*/
public class CharactersEvent extends DocumentBuilderEvent {
private final String text;
public CharactersEvent(String text) {
this.text = checkNotNull(text, "Must provide text"); //$NON-NLS-1$
}
@Override
public void invoke(DocumentBuilder builder) {
builder.characters(text);
}
/**
* Provides the text of this event.
*
* @return the text
*/
public String getText() {
return text;
}
@Override
public int hashCode() {
return Objects.hashCode(text);
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (obj == this) {
return true;
}
if (!(obj instanceof CharactersEvent)) {
return false;
}
CharactersEvent other = (CharactersEvent) obj;
return Objects.equal(other.text, text);
}
@Override
public String toString() {
return String.format("characters(\"%s\")", text); //$NON-NLS-1$
}
}
|