1 package org.apache.maven.doxia.sink;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import org.apache.commons.lang.builder.ToStringBuilder;
23
24 /**
25 * A single sink event, used for testing purposes in order to check
26 * the order and effect of some parser events.
27 *
28 * @author ltheussl
29 * @version $Id: SinkEventElement.java 1091043 2011-04-11 11:44:39Z ltheussl $
30 * @since 1.1
31 */
32 public class SinkEventElement
33 {
34 /** The name of the sink event, ie the sink method name. */
35 private final String methodName;
36
37 /** The array of arguments to the sink method. */
38 private final Object[] args;
39
40 /**
41 * A SinkEventElement is characterized by the method name and associated array of arguments.
42 *
43 * @param name The name of the sink event, ie the sink method name.
44 * @param arguments The array of arguments to the sink method.
45 * For a no-arg element this may be null or an empty array.
46 */
47 public SinkEventElement( String name, Object[] arguments )
48 {
49 if ( name == null )
50 {
51 throw new NullPointerException( "Element name can't be null!" );
52 }
53
54 this.methodName = name;
55 this.args = arguments;
56 }
57
58 /**
59 * Return the name of the this event.
60 *
61 * @return The name of the sink event.
62 */
63 public String getName()
64 {
65 return this.methodName;
66 }
67
68 /**
69 * Return the array of arguments to the sink method.
70 *
71 * @return the array of arguments to the sink method.
72 */
73 public Object[] getArgs()
74 {
75 return this.args;
76 }
77
78 /**
79 * {@inheritDoc}
80 * @since 1.1.1
81 */
82 @Override
83 public String toString()
84 {
85 return ToStringBuilder.reflectionToString( this );
86 }
87 }