1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.internal.event

File AbstractAttachmentEvent.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart8.png
54% of files have more coverage

Code metrics

0
5
4
1
89
26
4
0.8
1.25
4
1

Classes

Class Line # Actions
AbstractAttachmentEvent 32 5 0% 4 2
0.777777877.8%
 

Contributing tests

This file is covered by 61 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package com.xpn.xwiki.internal.event;
21   
22    import org.xwiki.bridge.event.AbstractDocumentEvent;
23    import org.xwiki.observation.event.filter.EventFilter;
24    import org.xwiki.observation.event.filter.FixedNameEventFilter;
25   
26    /**
27    * Base class for all attachment {@link org.xwiki.observation.event.Event events}.
28    *
29    * @version $Id: fffc22e78179267dc0fb1ffd3893217ae2e22ebd $
30    * @since 2.6RC2
31    */
 
32    public abstract class AbstractAttachmentEvent extends AbstractDocumentEvent
33    {
34    /**
35    * The version identifier for this Serializable class. Increment only if the <i>serialized</i> form of the class
36    * changes.
37    */
38    private static final long serialVersionUID = 1L;
39   
40    /**
41    * The name of the attachment that is used in events.
42    */
43    private String name;
44   
45    /**
46    * Constructor initializing the event filter with an
47    * {@link org.xwiki.observation.event.filter.AlwaysMatchingEventFilter}, meaning that this event will match any
48    * other attachment event (add, update, delete).
49    */
 
50  385 toggle public AbstractAttachmentEvent()
51    {
52  385 super();
53    }
54   
55    /**
56    * Constructor initializing the event filter with a {@link org.xwiki.observation.event.filter.FixedNameEventFilter},
57    * meaning that this event will match only attachment events affecting the document matching the passed document
58    * name.
59    *
60    * @param documentName the name of the updated document to match
61    * @param name the name of the attachment added/updated/deleted
62    */
 
63  446 toggle public AbstractAttachmentEvent(String documentName, String name)
64    {
65    // TODO: depreciate this constructor and add a constructor taking a document reference instead
66  446 super(new FixedNameEventFilter(documentName));
67  446 this.name = name;
68    }
69   
70    /**
71    * Constructor using a custom {@link EventFilter}.
72    *
73    * @param eventFilter the filter to use for matching events
74    */
 
75  0 toggle public AbstractAttachmentEvent(EventFilter eventFilter)
76    {
77  0 super(eventFilter);
78    }
79   
80    /**
81    * Retrieves the name of the attachment added/updated/deleted in the event.
82    *
83    * @return name name of the attachment
84    */
 
85  58 toggle public String getName()
86    {
87  58 return this.name;
88    }
89    }