1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.filter.xar.internal.input

File DocumentLocaleReader.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

98
195
31
1
595
441
93
0.48
6.29
31
3

Classes

Class Line # Actions
DocumentLocaleReader 67 195 0% 93 26
0.919753192%
 

Contributing tests

This file is covered by 62 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: 86df801bcfab3401d3aaf9d767f67fcf3ac0f36f $
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  12665 toggle public void setProperties(XARInputProperties properties)
129    {
130  12665 this.properties = properties;
131    }
132   
 
133  20331 toggle public EntityReference getSentSpaceReference()
134    {
135  20331 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  12676 toggle private void resetDocument()
149    {
150  12676 this.currentSpaceReference = null;
151  12676 this.currentLegacySpace = null;
152   
153  12676 this.currentDocumentReference = null;
154  12676 this.currentLegacyDocument = null;
155  12676 this.currentDocumentLocale = null;
156  12676 this.currentDocumentRevision = null;
157   
158  12676 this.currentDocumentParameters = new FilterEventParameters();
159    // Defaults
160  12676 this.currentDocumentParameters.put(WikiDocumentFilter.PARAMETER_LOCALE, Locale.ROOT);
161   
162  12676 this.currentDocumentLocaleParameters = new FilterEventParameters();
163  12676 this.currentDocumentRevisionParameters = new FilterEventParameters();
164   
165  12676 this.sentBeginWikiDocument = false;
166  12676 this.sentBeginWikiDocumentLocale = false;
167  12676 this.sentBeginWikiDocumentRevision = false;
168   
169  12676 this.localeFromLegacy = true;
170    }
171   
 
172  55163 toggle private void switchWikiSpace(XARInputFilter proxyFilter, boolean force) throws FilterException
173    {
174  55163 if (canSendEndWikiSpace(force)) {
175  7 sendEndWikiSpace(proxyFilter, force);
176    }
177   
178  55163 if (canSendBeginWikiSpace(force)) {
179  7669 sendBeginWikiSpace(proxyFilter, force);
180    }
181    }
182   
 
183  55163 toggle private boolean canSendBeginWikiSpace(boolean force)
184    {
185  55163 return (this.sentSpaceReference == null || !this.sentSpaceReference.equals(this.currentSpaceReference))
186    && (force || this.properties.getEntities() == null);
187    }
188   
 
189  7669 toggle private void sendBeginWikiSpace(XARInputFilter proxyFilter, boolean force) throws FilterException
190    {
191  7669 int sentSize = this.sentSpaceReference != null ? this.sentSpaceReference.size() : 0;
192  7669 int size = this.currentSpaceReference != null ? this.currentSpaceReference.size() : 0;
193   
194  7669 int diff = size - sentSize;
195   
196  7669 if (diff > 0) {
197  7669 List<EntityReference> spaces = this.currentSpaceReference.getReversedReferenceChain();
198  16332 for (int i = spaces.size() - diff; i < spaces.size(); ++i) {
199  8663 proxyFilter.beginWikiSpace(spaces.get(i).getName(), FilterEventParameters.EMPTY);
200  8663 this.sentSpaceReference =
201    new EntityReference(spaces.get(i).getName(), EntityType.SPACE, this.sentSpaceReference);
202    }
203    }
204    }
205   
 
206  55163 toggle private boolean canSendEndWikiSpace(boolean force)
207    {
208  55163 return this.sentSpaceReference != null && !this.sentSpaceReference.equals(this.currentSpaceReference)
209    && (force || this.properties.getEntities() == null);
210    }
211   
 
212  7 toggle private void sendEndWikiSpace(XARInputFilter proxyFilter, boolean force) throws FilterException
213    {
214  7 List<EntityReference> sentSpaces = this.sentSpaceReference.getReversedReferenceChain();
215  7 List<EntityReference> currentSpaces = this.currentSpaceReference.getReversedReferenceChain();
216   
217    // Find the first different level
218  7 int i = 0;
219  12 while (i < sentSpaces.size() && i < currentSpaces.size()) {
220  7 if (!currentSpaces.get(i).equals(sentSpaces.get(i))) {
221  2 break;
222    }
223   
224  5 ++i;
225    }
226   
227  7 if (i < sentSpaces.size()) {
228    // Delete what is different
229  15 for (int diff = sentSpaces.size() - i; diff > 0; --diff, this.sentSpaceReference =
230    this.sentSpaceReference.getParent()) {
231  9 proxyFilter.endWikiSpace(this.sentSpaceReference.getName(), FilterEventParameters.EMPTY);
232    }
233    }
234    }
235   
 
236  39811 toggle private boolean canSendBeginWikiDocument(boolean force)
237    {
238  39811 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  39811 toggle private void sendBeginWikiDocument(XARInputFilter proxyFilter, boolean force) throws FilterException
245    {
246  39811 switchWikiSpace(proxyFilter, force);
247   
248  39811 if (canSendBeginWikiDocument(force)) {
249  7675 switchWikiSpace(proxyFilter, true);
250   
251  7675 proxyFilter.beginWikiDocument(this.currentDocumentReference.getName(), this.currentDocumentParameters);
252  7675 this.sentBeginWikiDocument = true;
253    }
254    }
255   
 
256  7675 toggle private void sendEndWikiDocument(XARInputFilter proxyFilter) throws FilterException
257    {
258  7675 sendBeginWikiDocument(proxyFilter, true);
259  7675 sendEndWikiDocumentLocale(proxyFilter);
260   
261  7675 proxyFilter.endWikiDocument(this.currentDocumentReference.getName(), this.currentDocumentParameters);
262  7675 this.sentBeginWikiDocument = false;
263    }
264   
 
265  32136 toggle private boolean canSendBeginWikiDocumentLocale(boolean force)
266    {
267  32136 return this.sentBeginWikiDocument && !this.sentBeginWikiDocumentLocale
268    && (force || (this.currentDocumentLocale != null
269    && this.currentDocumentLocaleParameters.size() == XARDocumentModel.DOCUMENTLOCALE_PARAMETERS.size()));
270    }
271   
 
272  32143 toggle private void sendBeginWikiDocumentLocale(XARInputFilter proxyFilter, boolean force) throws FilterException
273    {
274  32143 if (force || (this.currentDocumentReference != null && this.currentDocumentLocale != null)) {
275  32138 LocalDocumentReference reference =
276    new LocalDocumentReference(this.currentDocumentReference, this.currentDocumentLocale);
277   
278  32138 if (this.properties.getEntities() != null && !this.properties.getEntities().matches(reference)) {
279  2 throw new SkipEntityException(reference);
280    }
281   
282  32136 sendBeginWikiDocument(proxyFilter, force);
283   
284  32136 if (canSendBeginWikiDocumentLocale(force)) {
285  7675 if (!this.properties.isWithHistory()) {
286  7530 this.currentDocumentLocaleParameters.remove(XWikiWikiDocumentFilter.PARAMETER_JRCSREVISIONS);
287    }
288   
289  7675 proxyFilter.beginWikiDocumentLocale(this.currentDocumentLocale, this.currentDocumentLocaleParameters);
290  7675 this.sentBeginWikiDocumentLocale = true;
291    }
292    }
293    }
294   
 
295  7675 toggle private void sendEndWikiDocumentLocale(XARInputFilter proxyFilter) throws FilterException
296    {
297  7675 sendBeginWikiDocumentLocale(proxyFilter, true);
298  7675 sendEndWikiDocumentRevision(proxyFilter);
299   
300  7675 proxyFilter.endWikiDocumentLocale(this.currentDocumentLocale, this.currentDocumentLocaleParameters);
301  7675 this.sentBeginWikiDocumentLocale = false;
302    }
303   
 
304  24466 toggle private boolean canSendBeginWikiDocumentRevision(boolean force)
305    {
306  24466 return this.sentBeginWikiDocumentLocale && !this.sentBeginWikiDocumentRevision
307    && (force || (this.currentDocumentRevision != null && this.currentDocumentRevisionParameters
308    .size() == XARDocumentModel.DOCUMENTREVISION_PARAMETERS.size()));
309    }
310   
 
311  24468 toggle private void sendBeginWikiDocumentRevision(XARInputFilter proxyFilter, boolean force) throws FilterException
312    {
313  24468 sendBeginWikiDocumentLocale(proxyFilter, force);
314   
315  24466 if (canSendBeginWikiDocumentRevision(force)) {
316  7675 proxyFilter.beginWikiDocumentRevision(this.currentDocumentRevision, this.currentDocumentRevisionParameters);
317  7675 this.sentBeginWikiDocumentRevision = true;
318    }
319    }
320   
 
321  7675 toggle private void sendEndWikiDocumentRevision(XARInputFilter proxyFilter) throws FilterException
322    {
323  7675 sendBeginWikiDocumentRevision(proxyFilter, true);
324   
325  7675 proxyFilter.endWikiDocumentRevision(this.currentDocumentRevision, this.currentDocumentRevisionParameters);
326  7675 this.sentBeginWikiDocumentRevision = false;
327    }
328   
 
329  12651 toggle public void read(Object filter, XARInputFilter proxyFilter) throws XMLStreamException, IOException, FilterException
330    {
331  12651 XMLStreamReader xmlReader = XMLInputFilterStreamUtils.createXMLStreamReader(this.properties);
332   
333  12651 try {
334  12651 read(xmlReader, filter, proxyFilter);
335    } finally {
336  12651 this.properties.getSource().close();
337    }
338    }
339   
 
340  25 toggle public void read(InputStream stream, Object filter, XARInputFilter proxyFilter)
341    throws XMLStreamException, FilterException
342    {
343  25 XMLStreamReader xmlReader = this.properties.getEncoding() != null
344    ? XML_INPUT_FACTORY.createXMLStreamReader(stream, this.properties.getEncoding())
345    : XML_INPUT_FACTORY.createXMLStreamReader(stream);
346   
347  25 read(xmlReader, filter, proxyFilter);
348    }
349   
 
350  12676 toggle public void read(XMLStreamReader xmlReader, Object filter, XARInputFilter proxyFilter)
351    throws XMLStreamException, FilterException
352    {
353  12676 resetDocument();
354   
355    // <xwikidoc>
356   
357  12676 xmlReader.nextTag();
358   
359  12676 this.currentSourceType = this.properties.getSourceType();
360  12676 if (this.currentSourceType != null) {
361  12636 switch (this.currentSourceType) {
362  1 case ATTACHMENT:
363  1 readAttachment(xmlReader, filter, proxyFilter);
364  1 break;
365   
366  4998 case CLASS:
367  4998 readClass(xmlReader, filter, proxyFilter);
368   
369  4998 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  7637 default:
387  7637 readDocument(xmlReader, filter, proxyFilter);
388   
389  7637 break;
390    }
391    } else {
392  40 readDocument(xmlReader, filter, proxyFilter);
393    }
394    }
395   
 
396  7677 toggle private void readDocument(XMLStreamReader xmlReader, Object filter, XARInputFilter proxyFilter)
397    throws XMLStreamException, FilterException
398    {
399  7677 xmlReader.require(XMLStreamReader.START_ELEMENT, null, XarDocumentModel.ELEMENT_DOCUMENT);
400   
401  7677 this.currentSourceType = SourceType.DOCUMENT;
402   
403    // Initialize with a few defaults (thing that don't exist in old XAR format)
404  7677 this.currentDocumentRevisionParameters.put(XWikiWikiDocumentFilter.PARAMETER_SYNTAX, Syntax.XWIKI_1_0);
405  7677 this.currentDocumentRevisionParameters.put(XWikiWikiDocumentFilter.PARAMETER_HIDDEN, false);
406   
407    // Reference
408  7677 String referenceString = xmlReader.getAttributeValue(null, XARDocumentModel.ATTRIBUTE_DOCUMENT_REFERENCE);
409  7677 if (StringUtils.isNotEmpty(referenceString)) {
410  5360 this.currentDocumentReference = this.relativeResolver.resolve(referenceString, EntityType.DOCUMENT);
411  5360 this.currentSpaceReference = this.currentDocumentReference.getParent();
412   
413    // Send needed wiki spaces event if possible
414  5360 switchWikiSpace(proxyFilter, false);
415    }
416   
417    // Locale
418  7677 String localeString = xmlReader.getAttributeValue(null, XARDocumentModel.ATTRIBUTE_DOCUMENT_LOCALE);
419  7677 if (localeString != null) {
420  5360 this.currentDocumentLocale = toLocale(localeString);
421  5360 this.localeFromLegacy = false;
422    }
423   
424  150007 for (xmlReader.nextTag(); xmlReader.isStartElement(); xmlReader.nextTag()) {
425  142330 String elementName = xmlReader.getLocalName();
426   
427  142330 if (elementName.equals(XARAttachmentModel.ELEMENT_ATTACHMENT)) {
428  1036 readAttachment(xmlReader, filter, proxyFilter);
429  141294 } else if (elementName.equals(XARObjectModel.ELEMENT_OBJECT)) {
430  7391 readObject(xmlReader, filter, proxyFilter);
431  133903 } else if (elementName.equals(XARClassModel.ELEMENT_CLASS)) {
432  689 readClass(xmlReader, filter, proxyFilter);
433    } else {
434  133214 String value = xmlReader.getElementText();
435   
436  133214 if (XarDocumentModel.ELEMENT_SPACE.equals(elementName)) {
437  7674 this.currentLegacySpace = value;
438   
439  7674 if (this.currentDocumentReference == null) {
440    // Its an old thing
441  2317 if (this.currentLegacyDocument == null) {
442  2317 this.currentSpaceReference = new EntityReference(value, EntityType.SPACE);
443    } else {
444  0 this.currentDocumentReference =
445    new LocalDocumentReference(this.currentLegacySpace, this.currentLegacyDocument);
446  0 this.currentSpaceReference = this.currentDocumentReference.getParent();
447    }
448   
449    // Send needed wiki spaces event if possible
450  2317 switchWikiSpace(proxyFilter, false);
451    }
452  125540 } else if (XarDocumentModel.ELEMENT_NAME.equals(elementName)) {
453  7674 this.currentLegacyDocument = value;
454   
455  7674 if (this.currentDocumentReference == null) {
456    // Its an old thing
457  2317 if (this.currentLegacySpace != null) {
458  2317 this.currentDocumentReference =
459    new LocalDocumentReference(this.currentLegacySpace, this.currentLegacyDocument);
460  2317 this.currentSpaceReference = this.currentDocumentReference.getParent();
461    }
462    }
463  117866 } else if (XarDocumentModel.ELEMENT_LOCALE.equals(elementName)) {
464  7672 if (this.localeFromLegacy) {
465  2315 this.currentDocumentLocale = toLocale(value);
466    }
467  110194 } else if (XarDocumentModel.ELEMENT_REVISION.equals(elementName)) {
468  7615 this.currentDocumentRevision = value;
469    } else {
470  102579 EventParameter parameter = XARDocumentModel.DOCUMENT_PARAMETERS.get(elementName);
471   
472  102579 if (parameter != null) {
473  7615 Object wsValue = convert(parameter.type, value);
474  7615 if (wsValue != null) {
475  7615 this.currentDocumentParameters.put(parameter.name, wsValue);
476    }
477    } else {
478  94964 parameter = XARDocumentModel.DOCUMENTLOCALE_PARAMETERS.get(elementName);
479   
480  94964 if (parameter != null) {
481  10300 Object wsValue = convert(parameter.type, value);
482  10300 if (wsValue != null) {
483  10300 this.currentDocumentLocaleParameters.put(parameter.name, wsValue);
484    }
485    } else {
486  84664 parameter = XARDocumentModel.DOCUMENTREVISION_PARAMETERS.get(elementName);
487   
488  84664 if (parameter != null) {
489  76656 Object objectValue;
490  76656 if (parameter.type == EntityReference.class) {
491  7460 objectValue = this.relativeResolver.resolve(value, EntityType.DOCUMENT);
492    } else {
493  69196 objectValue = convert(parameter.type, value);
494    }
495   
496  76656 if (objectValue != null) {
497  76233 this.currentDocumentRevisionParameters.put(parameter.name, objectValue);
498    }
499    } else {
500    // Unknown property
501    // TODO: log something ?
502    }
503    }
504    }
505    }
506    }
507    }
508   
509  7677 sendBeginWikiDocumentRevision(proxyFilter, true);
510  7675 sendWikiAttachments(proxyFilter);
511  7675 sendWikiClass(proxyFilter);
512  7675 sendWikiObjects(proxyFilter);
513  7675 sendEndWikiDocument(proxyFilter);
514    }
515   
 
516  7391 toggle private void readObject(XMLStreamReader xmlReader, Object filter, XARInputFilter proxyFilter)
517    throws XMLStreamException, FilterException
518    {
519  7391 if (this.currentSourceType == SourceType.DOCUMENT) {
520  7391 sendBeginWikiDocumentRevision(proxyFilter, false);
521    }
522   
523  7391 WikiObject wikiObject = this.objectReader.read(xmlReader, this.properties);
524   
525  7391 if (this.currentSourceType != SourceType.DOCUMENT || this.sentBeginWikiDocumentRevision) {
526  16 wikiObject.send(proxyFilter);
527    } else {
528  7375 this.currentObjects.offer(wikiObject);
529    }
530    }
531   
 
532  0 toggle private void readObjectProperty(XMLStreamReader xmlReader, Object filter, XARInputFilter proxyFilter)
533    throws XMLStreamException, FilterException
534    {
535  0 this.objectPropertyReader.read(xmlReader, this.properties).send(proxyFilter);
536    }
537   
 
538  5687 toggle private void readClass(XMLStreamReader xmlReader, Object filter, XARInputFilter proxyFilter)
539    throws XMLStreamException, FilterException
540    {
541  5687 if (this.currentSourceType == SourceType.DOCUMENT) {
542  689 sendBeginWikiDocumentRevision(proxyFilter, false);
543    }
544   
545  5687 this.currentClass = this.classReader.read(xmlReader, this.properties);
546   
547  5687 if (this.currentSourceType != SourceType.DOCUMENT || this.sentBeginWikiDocumentRevision) {
548  5006 sendWikiClass(proxyFilter);
549    }
550    }
551   
 
552  0 toggle private void readClassProperty(XMLStreamReader xmlReader, Object filter, XARInputFilter proxyFilter)
553    throws XMLStreamException, FilterException
554    {
555  0 this.classPropertyReader.read(xmlReader, this.properties).send(proxyFilter);
556    }
557   
 
558  1037 toggle private void readAttachment(XMLStreamReader xmlReader, Object filter, XARInputFilter proxyFilter)
559    throws XMLStreamException, FilterException
560    {
561  1037 if (this.currentSourceType == SourceType.DOCUMENT) {
562  1036 sendBeginWikiDocumentRevision(proxyFilter, false);
563    }
564   
565  1037 WikiAttachment wikiAttachment = this.attachmentReader.read(xmlReader, this.properties);
566   
567  1037 if (this.currentSourceType != SourceType.DOCUMENT || this.sentBeginWikiDocumentRevision) {
568  11 wikiAttachment.send(proxyFilter);
569    } else {
570  1026 this.currentAttachments.offer(wikiAttachment);
571    }
572    }
573   
 
574  12681 toggle private void sendWikiClass(XARInputFilter proxyFilter) throws FilterException
575    {
576  12681 if (this.currentClass != null && !this.currentClass.isEmpty()) {
577  5687 this.currentClass.send(proxyFilter);
578  5687 this.currentClass = null;
579    }
580    }
581   
 
582  7675 toggle private void sendWikiObjects(XARInputFilter proxyFilter) throws FilterException
583    {
584  15050 while (!this.currentObjects.isEmpty()) {
585  7375 this.currentObjects.poll().send(proxyFilter);
586    }
587    }
588   
 
589  7675 toggle private void sendWikiAttachments(XARInputFilter proxyFilter) throws FilterException
590    {
591  8701 while (!this.currentAttachments.isEmpty()) {
592  1026 this.currentAttachments.poll().send(proxyFilter);
593    }
594    }
595    }