1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.filter.xar.internal.input

File DocumentLocaleReader.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart9.png
38% of files have more coverage

Code metrics

98
194
31
1
593
440
94
0.48
6.26
31
3.03

Classes

Class Line # Actions
DocumentLocaleReader 67 194 0% 94 54
0.832817383.3%
 

Contributing tests

This file is covered by 52 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 org.xwiki.filter.xar.internal.input;
21   
22    import java.io.IOException;
23    import java.io.InputStream;
24    import java.util.LinkedList;
25    import java.util.List;
26    import java.util.Locale;
27    import java.util.Queue;
28   
29    import javax.inject.Inject;
30    import javax.inject.Named;
31    import javax.xml.stream.XMLInputFactory;
32    import javax.xml.stream.XMLStreamException;
33    import javax.xml.stream.XMLStreamReader;
34   
35    import org.apache.commons.lang3.StringUtils;
36    import org.xwiki.component.annotation.Component;
37    import org.xwiki.component.annotation.InstantiationStrategy;
38    import org.xwiki.component.descriptor.ComponentInstantiationStrategy;
39    import org.xwiki.filter.FilterEventParameters;
40    import org.xwiki.filter.FilterException;
41    import org.xwiki.filter.event.model.WikiDocumentFilter;
42    import org.xwiki.filter.event.xwiki.XWikiWikiDocumentFilter;
43    import org.xwiki.filter.xar.input.XARInputProperties;
44    import org.xwiki.filter.xar.input.XARInputProperties.SourceType;
45    import org.xwiki.filter.xar.internal.XARAttachmentModel;
46    import org.xwiki.filter.xar.internal.XARClassModel;
47    import org.xwiki.filter.xar.internal.XARDocumentModel;
48    import org.xwiki.filter.xar.internal.XARFilterUtils.EventParameter;
49    import org.xwiki.filter.xar.internal.XARObjectModel;
50    import org.xwiki.filter.xar.internal.input.AttachmentReader.WikiAttachment;
51    import org.xwiki.filter.xar.internal.input.ClassReader.WikiClass;
52    import org.xwiki.filter.xar.internal.input.WikiObjectReader.WikiObject;
53    import org.xwiki.filter.xml.internal.input.XMLInputFilterStreamUtils;
54    import org.xwiki.model.EntityType;
55    import org.xwiki.model.reference.EntityReference;
56    import org.xwiki.model.reference.EntityReferenceResolver;
57    import org.xwiki.model.reference.LocalDocumentReference;
58    import org.xwiki.rendering.syntax.Syntax;
59    import org.xwiki.xar.internal.model.XarDocumentModel;
60   
61    /**
62    * @version $Id: 90d16ab9e363c92d976e381cbadb6b966c1664d3 $
63    * @since 6.2M1
64    */
65    @Component(roles = DocumentLocaleReader.class)
66    @InstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP)
 
67    public class DocumentLocaleReader extends AbstractReader
68    {
69    private static final XMLInputFactory XML_INPUT_FACTORY = XMLInputFactory.newInstance();
70   
71    @Inject
72    @Named("relative")
73    private EntityReferenceResolver<String> relativeResolver;
74   
75    @Inject
76    private XARXMLReader<WikiObjectReader.WikiObject> objectReader;
77   
78    @Inject
79    private XARXMLReader<WikiObjectPropertyReader.WikiObjectProperty> objectPropertyReader;
80   
81    @Inject
82    private XARXMLReader<ClassReader.WikiClass> classReader;
83   
84    @Inject
85    private XARXMLReader<ClassPropertyReader.WikiClassProperty> classPropertyReader;
86   
87    @Inject
88    private XARXMLReader<AttachmentReader.WikiAttachment> attachmentReader;
89   
90    private XARInputProperties properties;
91   
92    private String currentLegacySpace;
93   
94    private String currentLegacyDocument;
95   
96    private EntityReference sentSpaceReference;
97   
98    private EntityReference currentSpaceReference;
99   
100    private EntityReference currentDocumentReference;
101   
102    private Locale currentDocumentLocale;
103   
104    private boolean localeFromLegacy = true;
105   
106    private String currentDocumentRevision;
107   
108    private FilterEventParameters currentDocumentParameters = new FilterEventParameters();
109   
110    private FilterEventParameters currentDocumentLocaleParameters = new FilterEventParameters();
111   
112    private FilterEventParameters currentDocumentRevisionParameters = new FilterEventParameters();
113   
114    private boolean sentBeginWikiDocument;
115   
116    private boolean sentBeginWikiDocumentLocale;
117   
118    private boolean sentBeginWikiDocumentRevision;
119   
120    private SourceType currentSourceType = SourceType.DOCUMENT;
121   
122    private WikiClass currentClass = new WikiClass();
123   
124    private Queue<WikiObject> currentObjects = new LinkedList<WikiObject>();
125   
126    private Queue<WikiAttachment> currentAttachments = new LinkedList<WikiAttachment>();
127   
 
128  4290 toggle public void setProperties(XARInputProperties properties)
129    {
130  4290 this.properties = properties;
131    }
132   
 
133  6834 toggle public EntityReference getSentSpaceReference()
134    {
135  6832 return this.sentSpaceReference;
136    }
137   
 
138  0 toggle public EntityReference getCurrentSpaceReference()
139    {
140  0 return this.currentSpaceReference;
141    }
142   
 
143  0 toggle public EntityReference getCurrentDocumentReference()
144    {
145  0 return this.currentDocumentReference;
146    }
147   
 
148  4292 toggle private void resetDocument()
149    {
150  4291 this.currentSpaceReference = null;
151  4289 this.currentLegacySpace = null;
152   
153  4291 this.currentDocumentReference = null;
154  4291 this.currentLegacyDocument = null;
155  4290 this.currentDocumentLocale = null;
156  4292 this.currentDocumentRevision = null;
157   
158  4291 this.currentDocumentParameters = new FilterEventParameters();
159    // Defaults
160  4294 this.currentDocumentParameters.put(WikiDocumentFilter.PARAMETER_LOCALE, Locale.ROOT);
161   
162  4288 this.currentDocumentLocaleParameters = new FilterEventParameters();
163  4288 this.currentDocumentRevisionParameters = new FilterEventParameters();
164   
165  4292 this.sentBeginWikiDocument = false;
166  4292 this.sentBeginWikiDocumentLocale = false;
167  4291 this.sentBeginWikiDocumentRevision = false;
168   
169  4291 this.localeFromLegacy = true;
170    }
171   
 
172  19018 toggle private void switchWikiSpace(XARInputFilter proxyFilter, boolean force) throws FilterException
173    {
174  19018 if (canSendEndWikiSpace(force)) {
175  0 sendEndWikiSpace(proxyFilter, force);
176    }
177   
178  19018 if (canSendBeginWikiSpace(force)) {
179  2545 sendBeginWikiSpace(proxyFilter, force);
180    }
181    }
182   
 
183  19018 toggle private boolean canSendBeginWikiSpace(boolean force)
184    {
185  19018 return (this.sentSpaceReference == null || !this.sentSpaceReference.equals(this.currentSpaceReference))
186    && (force || this.properties.getEntities() == null);
187    }
188   
 
189  2545 toggle private void sendBeginWikiSpace(XARInputFilter proxyFilter, boolean force) throws FilterException
190    {
191  2545 int sentSize = this.sentSpaceReference != null ? this.sentSpaceReference.size() : 0;
192  2545 int size = this.currentSpaceReference != null ? this.currentSpaceReference.size() : 0;
193   
194  2545 int diff = size - sentSize;
195   
196  2545 if (diff > 0) {
197  2545 List<EntityReference> spaces = this.currentSpaceReference.getReversedReferenceChain();
198  5094 for (int i = spaces.size() - diff; i < spaces.size(); ++i) {
199  2549 proxyFilter.beginWikiSpace(spaces.get(i).getName(), FilterEventParameters.EMPTY);
200  2549 this.sentSpaceReference =
201    new EntityReference(spaces.get(i).getName(), EntityType.SPACE, this.sentSpaceReference);
202    }
203    }
204    }
205   
 
206  19018 toggle private boolean canSendEndWikiSpace(boolean force)
207    {
208  19018 return this.sentSpaceReference != null && !this.sentSpaceReference.equals(this.currentSpaceReference)
209    && (force || this.properties.getEntities() == null);
210    }
211   
 
212  0 toggle private void sendEndWikiSpace(XARInputFilter proxyFilter, boolean force) throws FilterException
213    {
214  0 List<EntityReference> sentSpaces = this.sentSpaceReference.getReversedReferenceChain();
215  0 List<EntityReference> currentSpaces = this.currentSpaceReference.getReversedReferenceChain();
216   
217    // Find the first different level
218  0 int i = 0;
219  0 while (i < sentSpaces.size() && i < currentSpaces.size()) {
220  0 if (!currentSpaces.get(i).equals(sentSpaces.get(i))) {
221  0 break;
222    }
223   
224  0 ++i;
225    }
226   
227  0 if (i < sentSpaces.size()) {
228    // Delete what is different
229  0 for (int diff = sentSpaces.size() - i; diff > 0; --diff, this.sentSpaceReference =
230    this.sentSpaceReference.getParent()) {
231  0 proxyFilter.endWikiSpace(this.sentSpaceReference.getName(), FilterEventParameters.EMPTY);
232    }
233    }
234    }
235   
 
236  13922 toggle private boolean canSendBeginWikiDocument(boolean force)
237    {
238  13922 return this.sentSpaceReference != null && !this.sentBeginWikiDocument
239    && (force || (this.currentDocumentReference != null
240    && this.currentDocumentParameters.size() == XARDocumentModel.DOCUMENT_PARAMETERS.size()
241    && this.properties.getEntities() == null));
242    }
243   
 
244  13922 toggle private void sendBeginWikiDocument(XARInputFilter proxyFilter, boolean force) throws FilterException
245    {
246  13922 switchWikiSpace(proxyFilter, force);
247   
248  13922 if (canSendBeginWikiDocument(force)) {
249  2547 switchWikiSpace(proxyFilter, true);
250   
251  2547 proxyFilter.beginWikiDocument(this.currentDocumentReference.getName(), this.currentDocumentParameters);
252  2547 this.sentBeginWikiDocument = true;
253    }
254    }
255   
 
256  2547 toggle private void sendEndWikiDocument(XARInputFilter proxyFilter) throws FilterException
257    {
258  2547 sendBeginWikiDocument(proxyFilter, true);
259  2547 sendEndWikiDocumentLocale(proxyFilter);
260   
261  2547 proxyFilter.endWikiDocument(this.currentDocumentReference.getName(), this.currentDocumentParameters);
262  2547 this.sentBeginWikiDocument = false;
263    }
264   
 
265  11375 toggle private boolean canSendBeginWikiDocumentLocale(boolean force)
266    {
267  11375 return this.sentBeginWikiDocument && !this.sentBeginWikiDocumentLocale
268    && (force || (this.currentDocumentLocale != null
269    && this.currentDocumentLocaleParameters.size() == XARDocumentModel.DOCUMENTLOCALE_PARAMETERS.size()));
270    }
271   
 
272  11382 toggle private void sendBeginWikiDocumentLocale(XARInputFilter proxyFilter, boolean force) throws FilterException
273    {
274  11382 if (force || (this.currentDocumentReference != null && this.currentDocumentLocale != null)) {
275  11377 LocalDocumentReference reference =
276    new LocalDocumentReference(this.currentDocumentReference, this.currentDocumentLocale);
277   
278  11377 if (this.properties.getEntities() != null && !this.properties.getEntities().matches(reference)) {
279  2 throw new SkipEntityException(reference);
280    }
281   
282  11375 sendBeginWikiDocument(proxyFilter, force);
283   
284  11375 if (canSendBeginWikiDocumentLocale(force)) {
285  2547 if (!this.properties.isWithHistory()) {
286  2507 this.currentDocumentLocaleParameters.remove(XWikiWikiDocumentFilter.PARAMETER_JRCSREVISIONS);
287    }
288   
289  2547 proxyFilter.beginWikiDocumentLocale(this.currentDocumentLocale, this.currentDocumentLocaleParameters);
290  2547 this.sentBeginWikiDocumentLocale = true;
291    }
292    }
293    }
294   
 
295  2547 toggle private void sendEndWikiDocumentLocale(XARInputFilter proxyFilter) throws FilterException
296    {
297  2547 sendBeginWikiDocumentLocale(proxyFilter, true);
298  2547 sendEndWikiDocumentRevision(proxyFilter);
299   
300  2547 proxyFilter.endWikiDocumentLocale(this.currentDocumentLocale, this.currentDocumentLocaleParameters);
301  2547 this.sentBeginWikiDocumentLocale = false;
302    }
303   
 
304  8833 toggle private boolean canSendBeginWikiDocumentRevision(boolean force)
305    {
306  8833 return this.sentBeginWikiDocumentLocale && !this.sentBeginWikiDocumentRevision
307    && (force || (this.currentDocumentRevision != null && this.currentDocumentRevisionParameters
308    .size() == XARDocumentModel.DOCUMENTREVISION_PARAMETERS.size()));
309    }
310   
 
311  8835 toggle private void sendBeginWikiDocumentRevision(XARInputFilter proxyFilter, boolean force) throws FilterException
312    {
313  8835 sendBeginWikiDocumentLocale(proxyFilter, force);
314   
315  8833 if (canSendBeginWikiDocumentRevision(force)) {
316  2547 proxyFilter.beginWikiDocumentRevision(this.currentDocumentRevision, this.currentDocumentRevisionParameters);
317  2547 this.sentBeginWikiDocumentRevision = true;
318    }
319    }
320   
 
321  2547 toggle private void sendEndWikiDocumentRevision(XARInputFilter proxyFilter) throws FilterException
322    {
323  2547 sendBeginWikiDocumentRevision(proxyFilter, true);
324   
325  2547 proxyFilter.endWikiDocumentRevision(this.currentDocumentRevision, this.currentDocumentRevisionParameters);
326  2547 this.sentBeginWikiDocumentRevision = false;
327    }
328   
 
329  4283 toggle public void read(Object filter, XARInputFilter proxyFilter) throws XMLStreamException, IOException, FilterException
330    {
331  4283 XMLStreamReader xmlReader = XMLInputFilterStreamUtils.createXMLStreamReader(this.properties);
332   
333  4283 try {
334  4282 read(xmlReader, filter, proxyFilter);
335    } finally {
336  4282 this.properties.getSource().close();
337    }
338    }
339   
 
340  11 toggle public void read(InputStream stream, Object filter, XARInputFilter proxyFilter)
341    throws XMLStreamException, FilterException
342    {
343  11 XMLStreamReader xmlReader = this.properties.getEncoding() != null
344    ? XML_INPUT_FACTORY.createXMLStreamReader(stream, this.properties.getEncoding())
345    : XML_INPUT_FACTORY.createXMLStreamReader(stream);
346   
347  11 read(xmlReader, filter, proxyFilter);
348    }
349   
 
350  4291 toggle public void read(XMLStreamReader xmlReader, Object filter, XARInputFilter proxyFilter)
351    throws XMLStreamException, FilterException
352    {
353  4291 resetDocument();
354   
355    // <xwikidoc>
356   
357  4292 xmlReader.nextTag();
358   
359  4293 this.currentSourceType = this.properties.getSourceType();
360  4294 if (this.currentSourceType != null && this.currentSourceType != SourceType.DOCUMENT) {
361  1741 switch (this.currentSourceType) {
362  0 case ATTACHMENT:
363  0 readAttachment(xmlReader, filter, proxyFilter);
364  0 break;
365   
366  1740 case CLASS:
367  1740 readClass(xmlReader, filter, proxyFilter);
368   
369  1744 break;
370   
371  0 case CLASSPROPERTY:
372  0 readClassProperty(xmlReader, filter, proxyFilter);
373   
374  0 break;
375   
376  0 case OBJECT:
377  0 readObject(xmlReader, filter, proxyFilter);
378   
379  0 break;
380   
381  0 case OBJECTPROPERTY:
382  0 readObjectProperty(xmlReader, filter, proxyFilter);
383   
384  0 break;
385   
386  0 default:
387  0 break;
388    }
389    } else {
390  2549 xmlReader.require(XMLStreamReader.START_ELEMENT, null, XarDocumentModel.ELEMENT_DOCUMENT);
391   
392  2549 readDocument(xmlReader, filter, proxyFilter);
393    }
394    }
395   
 
396  2549 toggle private void readDocument(XMLStreamReader xmlReader, Object filter, XARInputFilter proxyFilter)
397    throws XMLStreamException, FilterException
398    {
399  2549 this.currentSourceType = SourceType.DOCUMENT;
400   
401    // Initialize with a few defaults (thing that don't exist in old XAR format)
402  2549 this.currentDocumentRevisionParameters.put(XWikiWikiDocumentFilter.PARAMETER_SYNTAX, Syntax.XWIKI_1_0);
403  2549 this.currentDocumentRevisionParameters.put(XWikiWikiDocumentFilter.PARAMETER_HIDDEN, false);
404   
405    // Reference
406  2549 String referenceString = xmlReader.getAttributeValue(null, XARDocumentModel.ATTRIBUTE_DOCUMENT_REFERENCE);
407  2549 if (StringUtils.isNotEmpty(referenceString)) {
408  967 this.currentDocumentReference = this.relativeResolver.resolve(referenceString, EntityType.DOCUMENT);
409  967 this.currentSpaceReference = this.currentDocumentReference.getParent();
410   
411    // Send needed wiki spaces event if possible
412  967 switchWikiSpace(proxyFilter, false);
413    }
414   
415    // Locale
416  2549 String localeString = xmlReader.getAttributeValue(null, XARDocumentModel.ATTRIBUTE_DOCUMENT_LOCALE);
417  2549 if (localeString != null) {
418  967 this.currentDocumentLocale = toLocale(localeString);
419  967 this.localeFromLegacy = false;
420    }
421   
422  57459 for (xmlReader.nextTag(); xmlReader.isStartElement(); xmlReader.nextTag()) {
423  54910 String elementName = xmlReader.getLocalName();
424   
425  54910 if (elementName.equals(XARAttachmentModel.ELEMENT_ATTACHMENT)) {
426  452 readAttachment(xmlReader, filter, proxyFilter);
427  54458 } else if (elementName.equals(XARObjectModel.ELEMENT_OBJECT)) {
428  2958 readObject(xmlReader, filter, proxyFilter);
429  51500 } else if (elementName.equals(XARClassModel.ELEMENT_CLASS)) {
430  329 readClass(xmlReader, filter, proxyFilter);
431    } else {
432  51171 String value = xmlReader.getElementText();
433   
434  51171 if (XarDocumentModel.ELEMENT_SPACE.equals(elementName)) {
435  2546 this.currentLegacySpace = value;
436   
437  2546 if (this.currentDocumentReference == null) {
438    // Its an old thing
439  1582 if (this.currentLegacyDocument == null) {
440  1582 this.currentSpaceReference = new EntityReference(value, EntityType.SPACE);
441    } else {
442  0 this.currentDocumentReference =
443    new LocalDocumentReference(this.currentLegacySpace, this.currentLegacyDocument);
444  0 this.currentSpaceReference = this.currentDocumentReference.getParent();
445    }
446   
447    // Send needed wiki spaces event if possible
448  1582 switchWikiSpace(proxyFilter, false);
449    }
450  48625 } else if (XarDocumentModel.ELEMENT_NAME.equals(elementName)) {
451  2546 this.currentLegacyDocument = value;
452   
453  2546 if (this.currentDocumentReference == null) {
454    // Its an old thing
455  1582 if (this.currentLegacySpace != null) {
456  1582 this.currentDocumentReference =
457    new LocalDocumentReference(this.currentLegacySpace, this.currentLegacyDocument);
458  1582 this.currentSpaceReference = this.currentDocumentReference.getParent();
459    }
460    }
461  46079 } else if (XarDocumentModel.ELEMENT_LOCALE.equals(elementName)) {
462  2544 if (this.localeFromLegacy) {
463  1580 this.currentDocumentLocale = toLocale(value);
464    }
465  43535 } else if (XarDocumentModel.ELEMENT_REVISION.equals(elementName)) {
466  2518 this.currentDocumentRevision = value;
467    } else {
468  41017 EventParameter parameter = XARDocumentModel.DOCUMENT_PARAMETERS.get(elementName);
469   
470  41017 if (parameter != null) {
471  2518 Object wsValue = convert(parameter.type, value);
472  2518 if (wsValue != null) {
473  2518 this.currentDocumentParameters.put(parameter.name, wsValue);
474    }
475    } else {
476  38499 parameter = XARDocumentModel.DOCUMENTLOCALE_PARAMETERS.get(elementName);
477   
478  38499 if (parameter != null) {
479  5044 Object wsValue = convert(parameter.type, value);
480  5044 if (wsValue != null) {
481  5044 this.currentDocumentLocaleParameters.put(parameter.name, wsValue);
482    }
483    } else {
484  33455 parameter = XARDocumentModel.DOCUMENTREVISION_PARAMETERS.get(elementName);
485   
486  33455 if (parameter != null) {
487  30569 Object objectValue;
488  30569 if (parameter.type == EntityReference.class) {
489  2460 objectValue = this.relativeResolver.resolve(value, EntityType.DOCUMENT);
490    } else {
491  28109 objectValue = convert(parameter.type, value);
492    }
493   
494  30569 if (objectValue != null) {
495  30162 this.currentDocumentRevisionParameters.put(parameter.name, objectValue);
496    }
497    } else {
498    // Unknown property
499    // TODO: log something ?
500    }
501    }
502    }
503    }
504    }
505    }
506   
507  2549 sendBeginWikiDocumentRevision(proxyFilter, true);
508  2547 sendWikiAttachments(proxyFilter);
509  2547 sendWikiClass(proxyFilter);
510  2547 sendWikiObjects(proxyFilter);
511  2547 sendEndWikiDocument(proxyFilter);
512    }
513   
 
514  2958 toggle private void readObject(XMLStreamReader xmlReader, Object filter, XARInputFilter proxyFilter)
515    throws XMLStreamException, FilterException
516    {
517  2958 if (this.currentSourceType == SourceType.DOCUMENT) {
518  2958 sendBeginWikiDocumentRevision(proxyFilter, false);
519    }
520   
521  2958 WikiObject wikiObject = this.objectReader.read(xmlReader, this.properties);
522   
523  2958 if (this.currentSourceType != SourceType.DOCUMENT || this.sentBeginWikiDocumentRevision) {
524  16 wikiObject.send(proxyFilter);
525    } else {
526  2942 this.currentObjects.offer(wikiObject);
527    }
528    }
529   
 
530  0 toggle private void readObjectProperty(XMLStreamReader xmlReader, Object filter, XARInputFilter proxyFilter)
531    throws XMLStreamException, FilterException
532    {
533  0 this.objectPropertyReader.read(xmlReader, this.properties).send(proxyFilter);
534    }
535   
 
536  2071 toggle private void readClass(XMLStreamReader xmlReader, Object filter, XARInputFilter proxyFilter)
537    throws XMLStreamException, FilterException
538    {
539  2072 if (this.currentSourceType == SourceType.DOCUMENT) {
540  329 sendBeginWikiDocumentRevision(proxyFilter, false);
541    }
542   
543  2073 this.currentClass = this.classReader.read(xmlReader, this.properties);
544   
545  2074 if (this.currentSourceType != SourceType.DOCUMENT || this.sentBeginWikiDocumentRevision) {
546  1753 sendWikiClass(proxyFilter);
547    }
548    }
549   
 
550  0 toggle private void readClassProperty(XMLStreamReader xmlReader, Object filter, XARInputFilter proxyFilter)
551    throws XMLStreamException, FilterException
552    {
553  0 this.classPropertyReader.read(xmlReader, this.properties).send(proxyFilter);
554    }
555   
 
556  452 toggle private void readAttachment(XMLStreamReader xmlReader, Object filter, XARInputFilter proxyFilter)
557    throws XMLStreamException, FilterException
558    {
559  452 if (this.currentSourceType == SourceType.DOCUMENT) {
560  452 sendBeginWikiDocumentRevision(proxyFilter, false);
561    }
562   
563  452 WikiAttachment wikiAttachment = this.attachmentReader.read(xmlReader, this.properties);
564   
565  452 if (this.currentSourceType != SourceType.DOCUMENT || this.sentBeginWikiDocumentRevision) {
566  8 wikiAttachment.send(proxyFilter);
567    } else {
568  444 this.currentAttachments.offer(wikiAttachment);
569    }
570    }
571   
 
572  4298 toggle private void sendWikiClass(XARInputFilter proxyFilter) throws FilterException
573    {
574  4298 if (this.currentClass != null && !this.currentClass.isEmpty()) {
575  2073 this.currentClass.send(proxyFilter);
576  2074 this.currentClass = null;
577    }
578    }
579   
 
580  2547 toggle private void sendWikiObjects(XARInputFilter proxyFilter) throws FilterException
581    {
582  5489 while (!this.currentObjects.isEmpty()) {
583  2942 this.currentObjects.poll().send(proxyFilter);
584    }
585    }
586   
 
587  2547 toggle private void sendWikiAttachments(XARInputFilter proxyFilter) throws FilterException
588    {
589  2991 while (!this.currentAttachments.isEmpty()) {
590  444 this.currentAttachments.poll().send(proxyFilter);
591    }
592    }
593    }