aoqi@0: /* aoqi@0: * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. Oracle designates this aoqi@0: * particular file as subject to the "Classpath" exception as provided aoqi@0: * by Oracle in the LICENSE file that accompanied this code. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: */ aoqi@0: aoqi@0: package com.sun.tools.internal.ws.processor.model; aoqi@0: aoqi@0: import java.util.Iterator; aoqi@0: aoqi@0: /** aoqi@0: * aoqi@0: * A model visitor incorporating all the logic required to walk through the model. aoqi@0: * aoqi@0: * @author WS Development Team aoqi@0: */ aoqi@0: public class ExtendedModelVisitor { aoqi@0: aoqi@0: public ExtendedModelVisitor() {} aoqi@0: aoqi@0: public void visit(Model model) throws Exception { aoqi@0: preVisit(model); aoqi@0: for (Service service : model.getServices()) { aoqi@0: preVisit(service); aoqi@0: for (Port port : service.getPorts()) { aoqi@0: preVisit(port); aoqi@0: if (shouldVisit(port)) { aoqi@0: for (Operation operation : port.getOperations()) { aoqi@0: preVisit(operation); aoqi@0: Request request = operation.getRequest(); aoqi@0: if (request != null) { aoqi@0: preVisit(request); aoqi@0: for (Iterator iter4 = request.getHeaderBlocks(); aoqi@0: iter4.hasNext();) { aoqi@0: aoqi@0: Block block = (Block) iter4.next(); aoqi@0: visitHeaderBlock(block); aoqi@0: } aoqi@0: for (Iterator iter4 = request.getBodyBlocks(); aoqi@0: iter4.hasNext();) { aoqi@0: aoqi@0: Block block = (Block) iter4.next(); aoqi@0: visitBodyBlock(block); aoqi@0: } aoqi@0: for (Iterator iter4 = request.getParameters(); aoqi@0: iter4.hasNext();) { aoqi@0: aoqi@0: Parameter parameter = (Parameter) iter4.next(); aoqi@0: visit(parameter); aoqi@0: } aoqi@0: postVisit(request); aoqi@0: } aoqi@0: aoqi@0: Response response = operation.getResponse(); aoqi@0: if (response != null) { aoqi@0: preVisit(response); aoqi@0: for (Iterator iter4 = response.getHeaderBlocks(); aoqi@0: iter4.hasNext();) { aoqi@0: aoqi@0: Block block = (Block) iter4.next(); aoqi@0: visitHeaderBlock(block); aoqi@0: } aoqi@0: for (Iterator iter4 = response.getBodyBlocks(); aoqi@0: iter4.hasNext();) { aoqi@0: aoqi@0: Block block = (Block) iter4.next(); aoqi@0: visitBodyBlock(block); aoqi@0: } aoqi@0: for (Iterator iter4 = response.getParameters(); aoqi@0: iter4.hasNext();) { aoqi@0: aoqi@0: Parameter parameter = (Parameter) iter4.next(); aoqi@0: visit(parameter); aoqi@0: } aoqi@0: postVisit(response); aoqi@0: } aoqi@0: aoqi@0: for (Iterator iter4 = operation.getFaults(); aoqi@0: iter4.hasNext();) { aoqi@0: aoqi@0: Fault fault = (Fault) iter4.next(); aoqi@0: preVisit(fault); aoqi@0: visitFaultBlock(fault.getBlock()); aoqi@0: postVisit(fault); aoqi@0: } aoqi@0: postVisit(operation); aoqi@0: } aoqi@0: } aoqi@0: postVisit(port); aoqi@0: } aoqi@0: postVisit(service); aoqi@0: } aoqi@0: postVisit(model); aoqi@0: } aoqi@0: aoqi@0: protected boolean shouldVisit(Port port) { aoqi@0: return true; aoqi@0: } aoqi@0: aoqi@0: // these methods are intended for subclasses aoqi@0: protected void preVisit(Model model) throws Exception {} aoqi@0: protected void postVisit(Model model) throws Exception {} aoqi@0: protected void preVisit(Service service) throws Exception {} aoqi@0: protected void postVisit(Service service) throws Exception {} aoqi@0: protected void preVisit(Port port) throws Exception {} aoqi@0: protected void postVisit(Port port) throws Exception {} aoqi@0: protected void preVisit(Operation operation) throws Exception {} aoqi@0: protected void postVisit(Operation operation) throws Exception {} aoqi@0: protected void preVisit(Request request) throws Exception {} aoqi@0: protected void postVisit(Request request) throws Exception {} aoqi@0: protected void preVisit(Response response) throws Exception {} aoqi@0: protected void postVisit(Response response) throws Exception {} aoqi@0: protected void preVisit(Fault fault) throws Exception {} aoqi@0: protected void postVisit(Fault fault) throws Exception {} aoqi@0: protected void visitBodyBlock(Block block) throws Exception {} aoqi@0: protected void visitHeaderBlock(Block block) throws Exception {} aoqi@0: protected void visitFaultBlock(Block block) throws Exception {} aoqi@0: protected void visit(Parameter parameter) throws Exception {} aoqi@0: }