Util
Keywords: uk.ac.ic.doc.automed.p2p.util.Util class

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## uk.ac.ic.doc.automed.p2p.util
Class Util

    java.lang.Object
      uk.ac.ic.doc.automed.p2p.util.Util

    public class Util

extends java.lang.Object

Author:
  Charis TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates

Constructor Summary
`Util()`

Method Summary
`static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage` | `getAdvertiseRequest(java.lang.String context, java.util.Map content)`
`static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage` | `getAskRequest(java.lang.String context, java.util.Map content)`
`static byte[]` | `getBytesFromInputStream(java.io.InputStream is, int bufferSize)` Get bytes array from an input stream
`static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage` | `getMessage(java.lang.String performative, java.lang.String context, java.util.Map content)`
`static byte[]` | `getMessageBytes(uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage mesg)` An overloading method of `getMessageBytes(String performative, String context, Map content)` to return an array of bytes for an `AbstractMessage` object
`static byte[]` | `getMessageBytes(java.lang.String performative, java.lang.String context, java.util.Map content)` An utility method to get byte-representation of an XML message This method is used in UDP communication
`static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage` | `getMessageFromBytes(byte[] dataBytes)` An utility method to construct an `AbstractMessage` from an array of `byte`s This method is used in UDP communication
`static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage` | `getMessageFromInput(java.io.InputStream inputStream)`
`static java.lang.Object` | `getNotNullObject(java.util.Map content, java.lang.String key)`
`static java.lang.String` | `getNotNullString(java.util.Map content, java.lang.String key)`
`static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage` | `getPathwayRequest(java.lang.String fromSchema, java.lang.String toSchema)`
`static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage` | `getPathwayToSourceRequest(java.lang.String schema)`
`static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage` | `getPortRequest(java.lang.String peerName)`
`static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage` | `getQueryRequest(java.lang.String schema, java.lang.String query)`
`static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage` | `getRecommendOneRequest(java.lang.String context, java.util.Map content)`
`static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage` | `getRegisterRequest(java.lang.String name, int port)`
`static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage` | `getSchemaRequest(java.lang.String schema)`
`static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage` | `getUnregisterRequest(java.lang.String name)` A message for peer unregistering from the local registry
`static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage` | `getUnsuccessfulMessage(uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage message, java.lang.String errorMsg, java.lang.String performative)`
`static java.lang.String` | `getXMLDocumentString(org.w3c.dom.Document doc)` Convert an XML document structure in to a printable string
`static java.lang.String` | `newID()`
`static void` | `outputConfirm(java.lang.String reqId, java.util.Map content, java.io.OutputStream os)` An overloading method of `#outputConfirm()` to output a confirmation message with optional content data
`static void` | `outputConfirm(java.lang.String reqId, java.io.OutputStream os)`
`static void` | `outputErrorMessage(uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage request, java.io.OutputStream os)`
`static void` | `outputErrorMessage(uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage request, java.lang.String message, java.io.OutputStream os)`
`static void` | `outputFailMessage(uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage request, java.io.OutputStream os)`
`static void` | `outputFailMessage(uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage request, java.lang.String message, java.io.OutputStream os)`
`static void` | `outputUnsuccessfulMessage(uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage request, java.lang.String message, java.lang.String performative, java.io.OutputStream os)`
`static java.lang.Object[]` | `parseFile(java.lang.String fileName)`
`static java.io.File` | `writeInFile(uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage message)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Util

    public Util()

Method Detail

### outputErrorMessage

    public static void outputErrorMessage(uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage request,
                                          java.io.OutputStream os)
                                   throws java.io.IOException

  Throws:
    `java.io.IOException`

### writeInFile

    public static java.io.File writeInFile(uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage message)

### outputErrorMessage

    public static void outputErrorMessage(uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage request,
                                          java.lang.String message,
                                          java.io.OutputStream os)
                                   throws java.io.IOException

  Throws:
    `java.io.IOException`

### outputFailMessage

    public static void outputFailMessage(uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage request,
                                         java.lang.String message,
                                         java.io.OutputStream os)
                                  throws java.io.IOException

  Throws:
    `java.io.IOException`

### outputFailMessage

    public static void outputFailMessage(uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage request,
                                         java.io.OutputStream os)
                                  throws java.io.IOException

  Throws:
    `java.io.IOException`

### outputUnsuccessfulMessage

    public static void outputUnsuccessfulMessage(uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage request,
                                                 java.lang.String message,
                                                 java.lang.String performative,
                                                 java.io.OutputStream os)
                                          throws java.io.IOException

  Throws:
    `java.io.IOException`

### outputConfirm

    public static void outputConfirm(java.lang.String reqId,
                                     java.io.OutputStream os)
                              throws java.io.IOException

  Throws:
    `java.io.IOException`

### outputConfirm

    public static void outputConfirm(java.lang.String reqId,
                                     java.util.Map content,
                                     java.io.OutputStream os)
                              throws java.io.IOException

  An overloading method of `#outputConfirm()` to output a confirmation message with optional content data

  Parameters:
    `reqId` - request id to use for reply
    `content` - a `Map` object for the optional content
    `output` - the `OutputStream` object for outputing result
  Throws:
    `java.io.IOException`

### getMessageFromInput

    public static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage getMessageFromInput(java.io.InputStream inputStream)

### getRegisterRequest

    public static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage getRegisterRequest(java.lang.String name,
                                                                                                     int port)

### getUnregisterRequest

    public static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage getUnregisterRequest(java.lang.String name)

  A message for peer unregistering from the local registry

### getPortRequest

    public static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage getPortRequest(java.lang.String peerName)

### getAdvertiseRequest

    public static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage getAdvertiseRequest(java.lang.String context,
                                                                                                      java.util.Map content)

### getPathwayToSourceRequest

    public static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage getPathwayToSourceRequest(java.lang.String schema)

### getPathwayRequest

    public static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage getPathwayRequest(java.lang.String fromSchema,
                                                                                                    java.lang.String toSchema)

### getQueryRequest

    public static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage getQueryRequest(java.lang.String schema,
                                                                                                  java.lang.String query)

### getSchemaRequest

    public static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage getSchemaRequest(java.lang.String schema)

### getAskRequest

    public static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage getAskRequest(java.lang.String context,
                                                                                                java.util.Map content)

### getRecommendOneRequest

    public static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage getRecommendOneRequest(java.lang.String context,
                                                                                                         java.util.Map content)

### getMessage

    public static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage getMessage(java.lang.String performative,
                                                                                             java.lang.String context,
                                                                                             java.util.Map content)

### newID

    public static java.lang.String newID()

### getNotNullObject

    public static java.lang.Object getNotNullObject(java.util.Map content,
                                                    java.lang.String key)
                                             throws uk.ac.ic.doc.automed.p2p.messages.abstractlayer.MalformedMessageException

  Throws:
    `uk.ac.ic.doc.automed.p2p.messages.abstractlayer.MalformedMessageException`

### getNotNullString

    public static java.lang.String getNotNullString(java.util.Map content,
                                                    java.lang.String key)
                                             throws uk.ac.ic.doc.automed.p2p.messages.abstractlayer.MalformedMessageException

  Throws:
    `uk.ac.ic.doc.automed.p2p.messages.abstractlayer.MalformedMessageException`

### getUnsuccessfulMessage

    public static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage getUnsuccessfulMessage(uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage message,
                                                                                                         java.lang.String errorMsg,
                                                                                                         java.lang.String performative)

### parseFile

    public static java.lang.Object[] parseFile(java.lang.String fileName)

### getXMLDocumentString

    public static java.lang.String getXMLDocumentString(org.w3c.dom.Document doc)

  Convert an XML document structure in to a printable string

  Parameters:
    `doc` - an XML document

### getMessageBytes

    public static byte[] getMessageBytes(java.lang.String performative,
                                         java.lang.String context,
                                         java.util.Map content)

  An utility method to get byte-representation of an XML message
  This method is used in UDP communication

  Parameters:
    `performative` - the message's performative
    `context` - the message's context
    `content` - a `Map` object of content fields

### getMessageBytes

    public static byte[] getMessageBytes(uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage mesg)

  An overloading method of `getMessageBytes(String performative, String context, Map content)`
  to return an array of bytes for an `AbstractMessage` object

  Parameters:
    `mesg` - `AbstractMessage` object to work with

### getMessageFromBytes

    public static uk.ac.ic.doc.automed.p2p.messages.abstractlayer.AbstractMessage getMessageFromBytes(byte[] dataBytes)
                                                                                               throws uk.ac.ic.doc.automed.p2p.messages.abstractlayer.MalformedMessageException

  An utility method to construct an `AbstractMessage` from an array of
  `byte`s This method is used in UDP communication

  Parameters:
    `performative` - the message's performative
    `context` - the message's context
    `content` - a `Map` object of content fields
  Throws:
    `uk.ac.ic.doc.automed.p2p.messages.abstractlayer.MalformedMessageException`

### getBytesFromInputStream

    public static byte[] getBytesFromInputStream(java.io.InputStream is,
                                                 int bufferSize)
                                          throws java.io.IOException

  Get bytes array from an input stream

  Throws:
    `java.io.IOException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD