@Override public void parse(Builder b) throws IOException { Logger.getLogger("org.jaudiotagger").setLevel(Level.OFF); try { audio = AudioFileIO.read(new File(src.path())); } catch (CannotReadException e) { System.out.println( "Detected empty or corrupt Music file '" + src.path() + "': " + e.getMessage()); } catch (TagException e) { System.out.println( "Detected empty or corrupt Music file '" + src.path() + "': " + e.getMessage()); } catch (ReadOnlyFileException e) { System.out.println( "Detected empty or corrupt Music file '" + src.path() + "': " + e.getMessage()); } catch (InvalidAudioFrameException e) { System.out.println( "Detected empty or corrupt Music file '" + src.path() + "': " + e.getMessage()); } try { builder = b; atts.add(NAME, token("." + src.name() + ".deepfs")); atts.add(TYPE, META); builder.startElem(FOLDER, atts); insertMusicMetadata(); builder.endElem(); } catch (IOException e) { e.printStackTrace(); } }
private void add(byte[] tag, byte[] text) throws IOException { if (text == null) return; atts.add(NAME, tag); atts.add(TYPE, tag); builder.startElem(FACT, atts); builder.text(text); builder.endElem(); atts.reset(); }
@Override public void parse(final Builder builder) throws IOException { builder.startDoc(token(filename)); final Stack<NodeIterator> stack = new Stack<NodeIterator>(); stack.push(new NodeIterator(root)); while (!stack.empty()) { final NodeIterator ni = stack.peek(); if (ni.more()) { final Node n = ni.curr(); if (n instanceof Element) { stack.push(new NodeIterator(n)); atts.reset(); final NamedNodeMap at = n.getAttributes(); for (int a = 0, as = at.getLength(); a < as; ++a) { final Attr att = (Attr) at.item(a); final byte[] k = token(att.getName()), v = token(att.getValue()); if (eq(k, XMLNS)) { builder.startNS(EMPTY, v); } else if (startsWith(k, XMLNSC)) { builder.startNS(ln(k), v); } else { atts.add(k, v); } } builder.startElem(token(n.getNodeName()), atts); } else if (n instanceof Text) { builder.text(new TokenBuilder(n.getNodeValue())); } else if (n instanceof Comment) { builder.comment(new TokenBuilder(n.getNodeValue())); } else if (n instanceof ProcessingInstruction) { builder.pi(new TokenBuilder(n.getNodeName() + ' ' + n.getNodeValue())); } ++nodes; } else { stack.pop(); if (stack.empty()) break; builder.endElem(token(stack.peek().curr().getNodeName())); } } builder.endDoc(); }