Package org.marc4j

Examples of org.marc4j.MarcException


    public Record next() {
        String[] tokens = line.trim().split("\t");
       
        if (tokens.length != 3)
            throw new MarcException("Index out of bounds");

        Record record = factory.newRecord("00000nz  a2200000o  4500");

        ControlField cf = factory.newControlField("001", tokens[0]);
        record.addVariableField(cf);
View Full Code Here


            rdr.parse(src);

            charsets = saxUms.getCharSets();
            combining = saxUms.getCombiningChars();
        } catch (Exception e) {
            throw new MarcException(e.getMessage(), e);
        }
    }
View Full Code Here

            rdr.parse(src);

            charsets = saxUms.getCharSets();
            combining = saxUms.getCombiningChars();
        } catch (Exception e) {
            throw new MarcException(e.getMessage(), e);
        }
    }
View Full Code Here

            rdr.parse(src);

            charsets = saxUms.getCharSets();
            combining = saxUms.getCombiningChars();
        } catch (Exception e) {
            throw new MarcException(e.getMessage(), e);
        }
    }  
View Full Code Here

                {
                    errorList.addError(ErrorHandler.MINOR_ERROR, "Escape character found at end of field, discarding it.");
                }
                else
                {
                    throw new MarcException("Escape character found at end of field");
                }
                break;
            }
            switch (data[cdt.offset + 1 + extra]) {
            case 0x28// '('
            case 0x2c// ','
                set_cdt(cdt, 0, data, 2 + extra, false);
                break;
            case 0x29// ')'
            case 0x2d// '-'
                set_cdt(cdt, 1, data, 2 + extra, false);
                break;
            case 0x24// '$'
                if (!loadedMultibyte) {
                    loadMultibyte();
                    loadedMultibyte = true;
                }
                switch (data[cdt.offset + 2 + extra + extra2]) {
                case 0x29// ')'
                case 0x2d// '-'
                    set_cdt(cdt, 1, data, 3 + extra + extra2, true);
                    break;
                case 0x2c// ','
                    set_cdt(cdt, 0, data, 3 + extra + extra2, true);
                    break;
                case 0x31// '1'
                    cdt.g0 = data[cdt.offset + 2 + extra + extra2];
                    cdt.offset += 3 + extra + extra2;
                    cdt.multibyte = true;
                    break;
                case 0x20// ' '
                    // space found in escape code: look ahead and try to proceed
                    extra2++;
                    break;
                default:
                    // unknown code character found: discard escape sequence and return
                    cdt.offset += 1;
                    if (errorList != null)
                    {
                        errorList.addError(ErrorHandler.MINOR_ERROR, "Unknown character set code found following escape character. Discarding escape character.");
                    }
                    else
                    {
                        throw new MarcException("Unknown character set code found following escape character.");
                    }
                    break;
                }
                break;
            case 0x67// 'g'
            case 0x62// 'b'
            case 0x70// 'p'
                cdt.g0 = data[cdt.offset + 1 + extra];
                cdt.offset += 2 + extra;
                cdt.multibyte = false;
                break;
            case 0x73// 's'
                cdt.g0 = 0x42;
                cdt.offset += 2 + extra;
                cdt.multibyte = false;
                break;
            case 0x20// ' '
                // space found in escape code: look ahead and try to proceed
                if (errorList == null)
                {
                    throw new MarcException("Extraneous space character found within MARC8 character set escape sequence");
                }
                extra++;
                break;
            default:
                // unknown code character found: discard escape sequence and return
                cdt.offset += 1;
                if (errorList != null)
                {
                    errorList.addError(ErrorHandler.MINOR_ERROR, "Unknown character set code found following escape character. Discarding escape character.");
                }
                else
                {
                    throw new MarcException("Unknown character set code found following escape character.");
                }
                break;
            }
        }
        if (errorList != null && ( extra != 0 || extra2 != 0))
View Full Code Here

            {
                errorList.addError(ErrorHandler.ERROR_TYPO, "Extraneous space character found within MARC8 character set escape sequence. Skipping over space.");
            }          
            else
            {
                throw new MarcException("Extraneous space character found within MARC8 character set escape sequence");
            }
            addnlOffset++;
        }
        else if ("(,)-$!".indexOf(data[cdt.offset + addnlOffset]) != -1)
        {
            if (errorList != null)
            {
                errorList.addError(ErrorHandler.MINOR_ERROR, "Extraneaous intermediate character found following escape character. Discarding intermediate character.");
            }          
            else
            {
                throw new MarcException("Extraneaous intermediate character found following escape character.");
            }
            addnlOffset++;
        }
        if ("34BE1NQS2".indexOf(data[cdt.offset + addnlOffset]) == -1)
        {
            cdt.offset += 1;
            cdt.multibyte = false;
            if (errorList != null)
            {
                errorList.addError(ErrorHandler.MINOR_ERROR, "Unknown character set code found following escape character. Discarding escape character.");
            }          
            else
            {
                throw new MarcException("Unknown character set code found following escape character.");
            }
        }
        else  // All is well, proceed normally
        {
            if (g0_or_g1 == 0) cdt.g0 = data[cdt.offset + addnlOffset];
View Full Code Here

TOP

Related Classes of org.marc4j.MarcException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.