SaxParser.parse(sok.getInputStream(), new handler()) [clarification please]

this code works, however i am not sure how/why?
i am interested in how Strings/characters are sent over tcp
streams:
here is sender:
Socket sok = new Socket(server, port);
OutputStreamWriter streamWriter = new OutputStreamWriter(sok.getOutputStream());
streamWriter.write(xmlString, 0, xmlString.length());i am ok with this.
i see that the OutputStreamWriter does "something" about converting the
socket's OutputStream to characters.
here is receiver:
SAXParser parser = saxFactory.newSAXParser();
Socket sok = serverSok.accept();
parser.parse(sok.getInputStream(), new MyHandler());see, i am plugging:
sok.getInputStream()
directly into the sax parser without providing context
that those bytes are characters (and what character encodings ).
so, what is going on? i might imagine using:
ObjectOutputStream.appendClass();
ObjectInputStream.resolveClass();to provide context that the byte stream are
characters of the "x" character set.
however, i am not using any
ObjectStreams.
if this is a ridiculous question, and the answer is
in the api somehow, i am sorry. i am not good
at always understanding the api.

then my fundamental confusion is the difference between
java.io.Reader;
java.io.InputStream;
consider the set of polymorphic method signatures for the
SAXParser parse () methods.
parser.parse(sok.getInputStream(), new MyHandler());clearly invokes:
public void parse(InputStream is, DefaultHandler dh);however i don't see any method signature that matches:
parser.parse(new InputStreamReader(sok.getInputStream(), myCharSet), new MyHandler());for example, in the api, there is no:
public void parse(Reader r, DefaultHandler dh);this has been very helpful.
i will Google the interchangability of Reader/InputStream tomorrow, however any
further guidance would be welcomed. the java.io heirarchy confuses me.

Similar Messages

  • Call handler clarification please!?

                       I was talking to a friend who's pretty into cisco unity connection and he told me this ... I can configure a call handler that will take a message and then broadcast that message to a dist list (fair enough and it works) but also after that try to call a number or several numbers and will leave the VM message in their mail boxes. After which when a person picks up the VM Unity will then erase the VM from the remaining mailboxes that didn't pick up the message.
    How this fits in is this ..
    I have a group of people (4) and I would like our help desk to call a number and leave a message. I would then like Unity to broadcast out an email to the 4 people, then (or before I don't really care about the order of it) try to call all 4 people and leave them the voicemail message. Once the designated person has picked up the VM it would then erase it from the rest of the peoples VM and voila a half decent solution is born instead of carrying around this rediculous pager we have to carry around.
    I know this might not work completely as described above, or maybe it does I'm not sure but I really need some help understanding the flow and config steps ...
    Thanks,
    BR

    Hi Brent,
    Your friend is most correct This is called Dispatch Messaging in Unity Connection;
    Dispatch Messages
    You can use the dispatch message feature to send a message to a  distribution list (from either a call handler or interview handler). The  message is configured such that only one user in the group needs to act  on the message. When listening to a dispatch message, users are given  the option to accept, postpone, or decline the message.
    Dispatch messages are handled as follows:
    •If  a user chooses to accept the message, all other copies of the message  are removed from the mailboxes of the other members of the distribution  list, regardless of whether the other users have listened to and  postponed the message.
    •If  a user chooses to postpone the message, it remains as an unread message  in the mailbox of that user and in the mailboxes of the other members  of the distribution list.
    •If  the user chooses to decline the message, it is removed from the mailbox  of that user, but copies of the message remain as unread in the  mailboxes of the other members of the distribution list.
    •If  there is only one copy of the dispatch message remaining, and no user  has yet chosen to accept the message, the final user whose mailbox it is  in must accept it. That user is not given the option to decline the  message.
    Dispatch messaging is useful in situations where a team is available to  respond to issues, but only one member of the team needs to respond. For  example, an IT department may want to set up a call handler to take  messages from employees who need assistance, and then send the messages  as dispatch messages to a distribution list comprised of IT department  staff. All of the members of the distribution list receive a copy of  each message. Team members can then decide whether to accept or decline a  message; declined messages are then picked up by other team members.
    http://www.cisco.com/en/US/docs/voice_ip_comm/connection/7x/administration/guide/7xcucsag170.html#Dispatch_Messages
    Cheers!
    Rob
    "Show a little faith, there's magic in the night" - Springsteen

  • Problems with using SAXParser.parse with an InputStream

    Hello:
    I have successfully run the echo01 program from the XML tutorial. I made the following changes to parse the output from a servlet which generates an XML document.
    URL recordedSensor = new URL("http://redbd01:8010/servlet/RecordedSensor?vin=1M000000000000001");
    URLConnection rsConn = recordedSensor.openConnection();
    // Parse the input
    SAXParser saxParser = factory.newSAXParser();
    saxParser.parse( rsConn.getInputStream(), handler);
    I get the following errors when I try to run the code.
    org.xml.sax.SAXParseException: java.lang.NullPointerException
    at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:524)
    at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)
    at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:442)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:393)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:191)
    at ServletInterface.main(ServletInterface.java:29)
    I think I have the problem narrowed down to the handlers accessing the class variable out which is a Writer the emit() method uses to output the document. When I replace out.write in emit() with System.out.println() the code works.
    I've tried accessing other class variables in the handler methods with similar results.
    Anybody encountered similar problems? And what is the solution.
    Thanks in advance,
    Gary

    I have the same problem, if you find a solution let me know. I've double checked my objects to make sure their not null, I've checked my constructors in the extended default handler, not really sure where else to look, its such a simple program....

  • All validation error from saxParser.parse

    I am getting just the 1st error but I want all the errors in the 1st pass itself.
    Attaching the code for reference also.
    ?would really appreciate you suggestion.
    ==code---
    public class EDITExtractSchema {
    static Document document;
    public void validateXMLVOusingXSD(String str)
    try {
    //create a SchemaFactory capable of understanding W3C XML Schemas (WXS)
    SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
    //Set the error handler to receive any error during Schema Compilation
    XMLErrorHandler errorHandler = new XMLErrorHandler();
    factory.setErrorHandler(errorHandler);
    //set the resource resolver to customize resource resolution
    //factory.setResourceResolver( new MyLSResourceResolver());
    // load a WXS schema, represented by a Schema instance
    File schemaFile = new File("C:/Temp/project2-CorrVO/XSDs/TaxExtract5498DetailVO.xsd");
    Schema schema = factory.newSchema(new StreamSource(schemaFile));
    SAXParserFactory spf = SAXParserFactory.newInstance();
    //spf.setNamespaceAware(true);
    //spf.setValidating(true);
    spf.setFeature("http://apache.org/xml/features/validation/schema-full-checking", true);
    //Just set the Schema instance on SAXParserFactory
    spf.setSchema(schema);
    //Obtain the SAXParser instance
    SAXParser saxParser = spf.newSAXParser();
    //parser will parse the XML document but validate it using Schema instance
    //saxParser.parse(new File(str), myHandler);
    saxParser.parse(new File(str),new MyDefaulyHandler());
    }catch(ParserConfigurationException e) {
    System.out.println("ParserConfigurationException-" + e);
    }catch (SAXException e) {
    System.out.println("SAXException-" + e);
    catch (Exception e) {
    System.out.println("Exception-" + e);
    /*// output the errors XML
    XMLWriter writer = null;
    try {
    writer = new XMLWriter(OutputFormat.createPrettyPrint());
    } catch (UnsupportedEncodingException e) {
    System.out.println("validate error" + e);
    e.printStackTrace();
    try {
    writer.write(errorHandler.geterrors());
    } catch (IOException e) {
    System.out.println("validate error" + e);
    e.printStackTrace();
    //implement error handler
    public static class XMLErrorHandler implements ErrorHandler {
    private boolean valid = true;
    public void reset() {
    // Assume document is valid until proven otherwise
    valid = true;
    public boolean isValid() {
    return valid;
    public void warning(SAXParseException exception) throws SAXException{
    System.out.println("Warning: " + exception.getMessage());
    System.out.println(" at line " + exception.getLineNumber()
    + ", column " + exception.getColumnNumber());
    System.out.println(" in entity " + exception.getSystemId());
    valid = true;
    public void error(SAXParseException exception) throws SAXException{
    System.out.println("Error: " + exception.getMessage());
    System.out.println(" at line " + exception.getLineNumber()
    + ", column " + exception.getColumnNumber());
    System.out.println(" in entity " + exception.getSystemId());
    valid = true;
    /* // output the errors XML
    XMLWriter writer = null;
    try {
    writer = new XMLWriter(OutputFormat.createPrettyPrint());
    } catch (UnsupportedEncodingException e) {
    System.out.println("validate error" + e);
    e.printStackTrace();
    try {
    writer.write((Object)exception);
    } catch (IOException e) {
    System.out.println("validate error" + e);
    e.printStackTrace();
    public void fatalError(SAXParseException exception) throws SAXException {
    System.out.println("Fatal Error: " + exception.getMessage());
    System.out.println(" at line " + exception.getLineNumber()
    + ", column " + exception.getColumnNumber());
    System.out.println(" in entity " + exception.getSystemId());
    valid = true;
    public static class MyDefaulyHandler extends DefaultHandler {
    private boolean valid = true;
    public void reset() {
    // Assume document is valid until proven otherwise
    valid = true;
    public boolean isValid() {
    return valid;
    public void warning(SAXParseException exception) throws SAXException{
    System.out.println("Warning: " + exception.getMessage());
    System.out.println(" at line " + exception.getLineNumber()
    + ", column " + exception.getColumnNumber());
    System.out.println(" in entity " + exception.getSystemId());
    valid = true;
    public void error(SAXParseException exception) throws SAXException{
    System.out.println("Error: " + exception.getMessage());
    System.out.println(" at line " + exception.getLineNumber()
    + ", column " + exception.getColumnNumber());
    System.out.println(" in entity " + exception.getSystemId());
    valid = true;
    /* // output the errors XML
    XMLWriter writer = null;
    try {
    writer = new XMLWriter(OutputFormat.createPrettyPrint());
    } catch (UnsupportedEncodingException e) {
    System.out.println("validate error" + e);
    e.printStackTrace();
    try {
    writer.write((Object)exception);
    } catch (IOException e) {
    System.out.println("validate error" + e);
    e.printStackTrace();
    public void fatalError(SAXParseException exception) throws SAXException {
    System.out.println("Fatal Error: " + exception.getMessage());
    System.out.println(" at line " + exception.getLineNumber()
    + ", column " + exception.getColumnNumber());
    System.out.println(" in entity " + exception.getSystemId());
    valid = true;
    public static void main(String[] args) {
    EDITExtractSchema schemaClass = new EDITExtractSchema();
    try {
    schemaClass.validateXMLVOusingXSD("C:/Temp/project2-CorrVO/XSDs/TaxExtract5498DetailVO.xml");
    }catch (Exception e) {
    System.out.println("xml file read error Exception-" + e);
    --====
    Regards,
    Tapas

    No really, it will report all the error if you turn on the validation and implement the error hander methods(error()).
    ALSO,
    My XSD had "<xs:sequence>" which was causing the problem.
    We had to change it to "<xs:all>". Now all the errors are getting reported.
    thx!

  • Javax.xml.parsers.SAXParser parser() error

    Hi,
    I've got some code that works fine in the Forte for Java IDE but just will not work when running as a stand-alone Windows application. I think it's to do with the filename having spaces in the pathname?
    Any help would be great!
    Regards.
    Gary Revell
    [email protected]
    [email protected]
    I've attached the code and the error(s) I get
    ------------------CODE FRAGMENT------------------
    // loadCE.java
    // Created on 25 April 2001, 15:43
    // @author RevellG
    // @version V1.0
    // This class is used to load the Standard Call Reporting XML document
    // and to allow the easy interrogation of the contents. The data can
    // then be used to populate fields in the Call Reporting GUI.
    import java.util.Vector;
    import java.io.*;
    import java.util.*;
    import java.util.Collections;
    import org.xml.sax.*;
    import javax.xml.parsers.SAXParserFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.SAXParser;
    public class loadCallElement extends Object
    private static loadCall loadCall = null;
    private static boolean DEBUG = false;
    // Creates new loadCE
    public loadCallElement(boolean debugFlag )
    this.DEBUG = debugFlag;
    public void parseDoc( String docName ) throws Throwable
    // Use the default (non-validating) parser
    SAXParserFactory factory = null;
    try
    // Parse the input
    factory = SAXParserFactory.newInstance();
    SAXParser saxParser = factory.newSAXParser();
    loadCall = new loadCall(DEBUG);
    saxParser.parse( new File( docName ), loadCall );
    catch (Throwable t)
    // catch ( Exception t )
    System.err.println( t.getMessage() +" - <"+docName+">");
    t.printStackTrace ();
    loadCall.ceTree.clear();
    throw t;
    ------------------Error and Stack Trace---------------
    E:\Support\Call Logs\bin>java -classpath .\SCM_GUI.jar;%CLASSPATH%;%XML_HOME%\jaxp.jar;%XML_HOME%\parser.jar M
    anagerInterface > g.g
    CWD /Telecom/Support/Call Logs/Logs/Open/BBC PICS/001$revellg$qwerty.xml: 550 /Telecom/Support/Call Logs/Logs/
    Open/BBC PICS/001$revellg$qwerty.xml: The system cannot find the path specified.
    - <\\Reoclu1\Telecom\Support\Call Logs\Logs\Open\BBC PICS\001$revellg$qwerty.xml>
    java.io.FileNotFoundException: CWD /Telecom/Support/Call Logs/Logs/Open/BBC PICS/001$revellg$qwerty.xml: 550 /
    Telecom/Support/Call Logs/Logs/Open/BBC PICS/001$revellg$qwerty.xml: The system cannot find the path specified
    at sun.net.ftp.FtpClient.readReply(Unknown Source)
    at sun.net.ftp.FtpClient.issueCommand(Unknown Source)
    at sun.net.ftp.FtpClient.issueCommandCheck(Unknown Source)
    at sun.net.ftp.FtpClient.cd(Unknown Source)
    at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(Unknown Source)
    at java.net.URL.openStream(Unknown Source)
    at com.sun.xml.parser.InputEntity.init(InputEntity.java:141)
    at com.sun.xml.parser.Parser.parseInternal(Parser.java:463)
    at com.sun.xml.parser.Parser.parse(Parser.java:284)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:155)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:126)
    at loadCallElement.parseDoc(loadCallElement.java:52)
    at SCMView.create(SCMView.java, Compiled Code)
    at EventController$5.actionPerformed(EventController.java:116)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

    Thanks Jim,
    I've installed JDK V1.3.1 and the problem HAS gone away..... However now JDK V1.3.1 won't install on other Win 2K machines.....
    Gary.

  • When I try to publish a video in CS5 it adds the extension .new. Help please!

    When I try to publish a video in CS5 it adds the extension .new. Help please!

    Your video is encoded in a format that PS doesn't understand. It's as easy as that. AVIs are just containers that can contain a multitude of different CoDecs and settings. You will have to do some reading up on that matter and then use external programs like VirtualDub, MPEGStreamclip and otehrs to convert your file to something PS understands - if that realyl is what you need. Otehrwise simply move on to "real" video editing apps that can handle all that much better.
    Mylenium

  • Creation of new handling unit management storage location

    Hello
    I am using transaction HU02 and create a handling unit from existing material. But i don't have any HU management storage locations in the system.
    Could you please explain me how to create a HUM storage location?
    Thanks,
    Ilya

    Hello,
    I am trying to create new Handling unit, with HU02 t-code, and i am getting the following errror:
    The number range object 1 does not exist
    Message no. NR002
    Diagnosis
    The number range object was not defined.
    Procedure
    Maintain the specified number range object using Transaction SNRO.
    I've customized number range for object LE_SSCC in SNRO.
    Сould you please advise, what is my mistake?
    Thx in advance

  • Is there a way to run a 2005 PreSonus Firebox(with the firewire) to a mid-2011 iMac 0SX 10.7.2? It says its no longer supporting Power PC? Anything I can do without spending more money on new equipment or a new computer? Please help me.

    Is there a way to run a 2005 PreSonus Firebox(with the firewire) to a mid-2011 iMac 0SX 10.7.2? It says its no longer supporting Power PC? Anything I can do without spending more money on new equipment or a new computer? Please help me.

    Nevermind, I got it working.
    I ended up extracting the new vob within MPEG Streamclip, which gave me an m2v and an aiff audio. I multiplexed those two back together in FFMpegX which gave me a complete VIDEO_TS folder with BUP and IFO files I needed.

  • I changed my email address for my apple id but icloud still has old email adress and when I try to signout so I can sign in with new address it asks for password and then says invalid so I cannot delete the account to sign in with the new one! Please help

    I changed my email address for my apple id but icloud still has old email adress and when I try to signout so I can sign in with new address it asks for password and then says invalid so I cannot delete the account to sign in with the new one! Please help

    OK...now I appear to 'progressed' I changed my email address back to original on Apple id and then was able to delete icloud account. Apparently I couldnt do it as it kept requesting password  when I entered passsword ( both old and new one, it wouldnt accept it as it had my old email address in ) It didnt do that on ios6 . Anyway I deleted account, but now I tried to login in with my new id/password and it says unable as already in use!!! More help needed please! Its a nightmare!!

  • Hello Guys. I had problems in the Computer before and changed my HD. I saved in my all files documents in (Time Capsule). How can I put all my files, pictures documents on my new HD? Please Help. Thank You

    Hello Guys.
    I had problems in the Computer before and changed my HD. I saved in my all files documents in (Time Capsule). How can I put all my files, pictures documents on my new HD?
    Please Help.
    Thank You
    Julio Skov

    Hey
    Thank you very much for replay.
    Would you explain to me how can I do?
    I don't really understand these processes.
    Thak you very much
    Julio

  • HT201272 I purchased an audiobook in Nov 2012 using iPhone 4S and then upgraded to iPhone 5 in Dec. Now I am not seeing the audio book in purchase history in iTunes. This means I am not able to get the book in my new iPhone. Please help

    I purchased an audiobook in Nov 2012 using iPhone 4S and then upgraded to iPhone 5 in Dec. Now I am not seeing the audio book in purchase history in iTunes. This means I am not able to get the book in my new iPhone. Please help.

    Audiobooks are currently a one-time only download from the store. If you don't have it on your computer (audiobooks go into the Books part of your iTunes library) nor on a backup, then if it's still in the store you can try contacting iTunes support and see if they will grant you a re-download : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page

  • I have no trouble viewing apps in the iTunes Store on my iPad. However, every time I try to install a new app, I get an error message after a while - cannot connect to iTunes Store. This issues cropped up two days ago on my new iPad. Please help...

    I have no trouble viewing apps in the iTunes Store on my iPad. However, every time I try to install a new app, I get an error message after a while - cannot connect to iTunes Store. This issues cropped up two days ago on my new iPad. Please help...

    JUst experienced the exact  same problem after changing password.Getting same message. Hope someone has an answer for this.

  • Hi can anyone help me. I have a apple macbook laptop OSX 10.5.8 . When i push print, it shows my printer but says cannot communicate with printer. (epson stylus nx125). Do I need new drivers? Please help .  regards Cindy

    Hi can anyone help me. I have a apple macbook laptop OSX 10.5.8 . When i push print, it shows my printer but says cannot communicate with printer. (epson stylus nx125). Do I need new drivers? Please help .  regards Cindy

    Welcome to Apple Support Communities. We're users here and do not speak for "Apple Inc."
    Some basic printer troubleshooting steps before worrying about a printer driver:
    1. Have you tried turning the printer off and back on?
    2A. Is the printer attached with a cable?
         If yes, have you tried unplugging and re-plugging both ends of the printer cable?
         If that does not help, can you test the printer with another cable?
    2B. If your printer is not connected to the computer with a cable, have you tried restarting your printer (assuming wireless connection)?
         Have you tried restarting your wireless router?
    3. Have you tried restarting your MacBook? (Be sure to save your work first.)
    4. Does the printer have ink? (Doesn't usually generate a 'communications error' though)
    5. Have you updated OS X or the program you're trying to print from recently?

  • Why does the Right-click - "t" delete a bookmark on the bookmark toolbar, when Right-click - "t" opens a new tab elsewhere. The bookmark toolbar use Right-click - "w" to open in a new tab. Please change this to "t" to...

    Why does the Right-click -> "t" delete a bookmark on the bookmark toolbar, when Right-click -> "t" opens a new tab elsewhere in Firefox. The bookmark toolbar use Right-click -> "w" to open in a new tab. Please change this to "t" to... I keep deleting all my bookmark because you don't make the commands consistent!

    If you have accidentally removed bookmarks then use "Organize > Undo" in the bookmarks manager (Bookmarks > Organize Bookmarks) to get them back.<br />
    The Organize button is the first of the three buttons on the toolbar in the Library (Bookmarks Manager).<br />
    That only works if you haven't closed Firefox.
    [https://bugzilla.mozilla.org/show_bug.cgi?id=301888 Bug 301888] – Bookmarks cut instead of opened in new tab from Bookmarks Toolbar Folder
    (please do not comment in bug reports; you can vote instead)

  • Creating a new Handler (java.util.logging API)

    Hi,
    I'm developping a new Handler (extending the java.util.logging.StreamHandler) and I need to get some initialisation properties from the LogManager. I was taking example from the existing Handlers (SocketHandler, FileHandler...) and wanted to use the LogManager.getLevelProperty, getFilterProperty and so on). Unfortunately these methods are not public.
    Is there any good reason for that ? As we are still dealing with a beta version, can't we have them public (same old Open Source problem).
    Antonio

    I am in a similar situation and agree completely with the above comments. Using the LogManager getProperty() is incredibly cumbersome.
    Ciao Ric

Maybe you are looking for