Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.vex.core/src/org/eclipse/vex/core/dom/BaseNodeVisitorWithResult.java')
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/dom/BaseNodeVisitorWithResult.java52
1 files changed, 52 insertions, 0 deletions
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/dom/BaseNodeVisitorWithResult.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/dom/BaseNodeVisitorWithResult.java
new file mode 100644
index 00000000..6df85fdc
--- /dev/null
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/dom/BaseNodeVisitorWithResult.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 Florian Thienel 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:
+ * Florian Thienel - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.vex.core.dom;
+
+/**
+ * This class provides default implementations for the methods defined by the <code>INodeVisitorWithResult</code>
+ * interface. An overloaded variant of the constructor allows to define a default value which is returned by the
+ * unimplemented visit methods.
+ *
+ * @see INodeVisitorWithResult
+ * @author Florian Thienel
+ */
+public class BaseNodeVisitorWithResult<T> implements INodeVisitorWithResult<T> {
+
+ private final T defaultValue;
+
+ public BaseNodeVisitorWithResult() {
+ this(null);
+ }
+
+ public BaseNodeVisitorWithResult(final T defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ public T visit(final IDocument document) {
+ return defaultValue;
+ }
+
+ public T visit(final IDocumentFragment fragment) {
+ return defaultValue;
+ }
+
+ public T visit(final IElement element) {
+ return defaultValue;
+ }
+
+ public T visit(final IText text) {
+ return defaultValue;
+ }
+
+ public T visit(final IComment comment) {
+ return defaultValue;
+ }
+}

Back to the top