You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AbortableHSSFListener.java 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.hssf.eventusermodel;
  16. import org.apache.poi.hssf.record.Record;
  17. /**
  18. * Abstract class for use with the HSSFRequest and HSSFEventFactory, which
  19. * allows for the halting of processing.
  20. * Users should create subclass of this (which implements the usual
  21. * HSSFListener), and then override the #abortableProcessRecord(org.apache.poi.hssf.record.Record)
  22. * method to do their processing.
  23. * This should then be registered with the HSSFRequest (associating
  24. * it with Record SID's) as usual.
  25. *
  26. * @see org.apache.poi.hssf.eventusermodel.HSSFEventFactory
  27. * @see org.apache.poi.hssf.eventusermodel.HSSFRequest
  28. * @see org.apache.poi.hssf.eventusermodel.HSSFUserException
  29. */
  30. public abstract class AbortableHSSFListener implements HSSFListener
  31. {
  32. /**
  33. * This method, inherited from HSSFListener is implemented as a stub.
  34. * It is never called by HSSFEventFactory or HSSFRequest.
  35. * You should implement #abortableProcessRecord instead
  36. */
  37. @Override
  38. public void processRecord(org.apache.poi.hssf.record.Record record)
  39. {
  40. }
  41. /**
  42. * Process an HSSF Record. Called when a record occurs in an HSSF file.
  43. * Provides two options for halting the processing of the HSSF file.
  44. *
  45. * The return value provides a means of non-error termination with a
  46. * user-defined result code. A value of zero must be returned to
  47. * continue processing, any other value will halt processing by
  48. * <code>HSSFEventFactory</code> with the code being passed back by
  49. * its abortable process events methods.
  50. *
  51. * Error termination can be done by throwing the HSSFUserException.
  52. *
  53. * Note that HSSFEventFactory will not call the inherited process
  54. *
  55. * @param record the record to be processed
  56. *
  57. * @return result code of zero for continued processing.
  58. *
  59. * @throws HSSFUserException User code can throw this to abort
  60. * file processing by HSSFEventFactory and return diagnostic information.
  61. */
  62. public abstract short abortableProcessRecord(org.apache.poi.hssf.record.Record record) throws HSSFUserException;
  63. }