Method: getTextContent()

1: /*
2: * #%~
3: * org.overture.ide.debug
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.ide.debug.core.dbgp.internal.packets;
23:
24: import org.w3c.dom.Element;
25:
26: public class DbgpStreamPacket extends DbgpPacket
27: {
28:         private static final String STDERR = "stderr"; //$NON-NLS-1$
29:
30:         private static final String STDOUT = "stdout"; //$NON-NLS-1$
31:
32:         private final String type;
33:
34:         private final String textContent;
35:
36:         public DbgpStreamPacket(String type, String textContent, Element content)
37:         {
38:                 super(content);
39:
40:                 if (!STDERR.equalsIgnoreCase(type) && !STDOUT.equalsIgnoreCase(type))
41:                 {
42:                         throw new IllegalArgumentException("invalidTypeValue");
43:                 }
44:
45:                 if (textContent == null)
46:                 {
47:                         throw new IllegalArgumentException("contentCannotBeNull");
48:                 }
49:
50:                 this.type = type;
51:                 this.textContent = textContent;
52:         }
53:
54:         public boolean isStdout()
55:         {
56:                 return STDOUT.equalsIgnoreCase(type);
57:         }
58:
59:         public boolean isStderr()
60:         {
61:                 return STDERR.equalsIgnoreCase(type);
62:         }
63:
64:         public String getTextContent()
65:         {
66:                 return textContent;
67:         }
68:
69:         public String toString()
70:         {
71:                 return "DbgpStreamPacket (Type: " + type + "; Content: " + textContent //$NON-NLS-1$ //$NON-NLS-2$
72:                                 + ";)"; //$NON-NLS-1$
73:         }
74: }