Get a builder by pattern form given {@link GatewayMessage}.

@param message Message form where to copy field values.
@return builder with fields copied from given {@link GatewayMessage}
765247
public static Builder from(GatewayMessage message) {
    return new Builder().headers(message.headers).data(message.data);
  }
803628
public GelfMessage build() {
        if (message == null) {
            throw new IllegalArgumentException("message must not be null!");
        }

        if (host == null || host.trim().isEmpty()) {
            throw new IllegalArgumentException("host must not be null or empty!");
        }

        if (version == null) {
            throw new IllegalArgumentException("version must not be null!");
        }

        final GelfMessage gelfMessage = new GelfMessage(message, host, version);

        gelfMessage.setLevel(level);

        if (fullMessage != null) {
            gelfMessage.setFullMessage(fullMessage);
        }

        if (timestamp != null) {
            gelfMessage.setTimestamp(timestamp);
        }

        gelfMessage.addAdditionalFields(fields);

        return gelfMessage;
    }
349686
public String getMessage(String message, Object[] args)
    {
        for (int i=0;i<args.length;i++)
        {
            if (args[i] instanceof List<?>)
            {
                @SuppressWarnings("unchecked")
				List<ProxyField> list = (List<ProxyField>)args[i];
                StringBuilder sb = new StringBuilder();
                for (ProxyField pf: list)
                {
                    sb.append(String.valueOf(pf.getValue()));
                    sb.append(",");
                }
                if (sb.length()>0)
                {
                    args[i] = sb.substring(0, sb.length()-1);
                }
                else
                {
                    args[i] = "";
                }
            }
        }
        return m_messageSourceAccessor.getMessage(message, args);
    }
565678
public static Messaging getMessaging(final Jaxb2Marshaller jaxb2Marshaller, final WebServiceMessage message) {

        SoapHeader soapHeader = ((SoapMessage) message).getSoapHeader();
        if (soapHeader == null) {
            throw new RuntimeException("The ebMS header is missing (no SOAP header found in SOAP request)");
        }

        Iterator<SoapHeaderElement> soapHeaderElementIterator = soapHeader.examineHeaderElements(MESSAGING_QNAME);
        if (!soapHeaderElementIterator.hasNext()) {
            throw new RuntimeException("The ebMS header is missing in SOAP header");
        }

        SoapHeaderElement incomingSoapHeaderElement = soapHeaderElementIterator.next();
        try {
            return (Messaging) jaxb2Marshaller.unmarshal(incomingSoapHeaderElement.getSource());
        } catch (Exception e) {
            throw new RuntimeException("The ebMs header failed to unmarshall");
        }

    }
554638
public RepeatedFieldBuilder<MType, BType, IType> addAllMessages(
      final Iterable<? extends MType> values) {
    for (final MType value : values) {
      if (value == null) {
        throw new NullPointerException();
      }
    }
    if (values instanceof Collection) {
      @SuppressWarnings("unchecked")
      final Collection<MType> collection = (Collection<MType>) values;
      if (collection.size() == 0) {
        return this;
      }
      ensureMutableMessageList();
      for (final MType value : values) {
        addMessage(value);
      }
    } else {
      ensureMutableMessageList();
      for (final MType value : values) {
        addMessage(value);
      }
    }
    onChanged();
    incrementModCounts();
    return this;
  }
1305579
public Response executeMessage(Message message, Builder<?> builder) {
    return executeMessage(message, builder,
                          OperaIntervals.RESPONSE_TIMEOUT.getMs());
  }
818231
public Mail withBuilder(Email email) {
        Objects.requireNonNull(email, Required.EMAIL.toString());
        this.email = email;
        
        return this;
    }
172287
public static <M extends PMessage<M,F>, F extends PField>
    MessageFieldArgument<M,F> toField(M message, F field) {
        return new MessageFieldArgument<>(message, field);
    }
1287807
public static List<CharSequence> getBodies(Message message) {
        XHTMLExtension xhtmlExtension = XHTMLExtension.from(message);
        if (xhtmlExtension != null)
            return xhtmlExtension.getBodies();
        else
            return null;
    }
750300
FieldBuilder getFieldBuilder(Element element) {
        FieldBuilder fieldBuilder = new FieldBuilder(messager, element);
        fieldBuilder.setBindingManager(this);
        return fieldBuilder;
    }
774158
public static <T extends Throwable> Matcher<T> withMessage(String message) {
        return IsThrowable.withMessage(message);
    }
971586
public BType getBuilder(int index) {
    ensureBuilders();
    SingleFieldBuilder<MType, BType, IType> builder = builders.get(index);
    if (builder == null) {
      MType message = messages.get(index);
      builder = new SingleFieldBuilder<MType, BType, IType>(
          message, this, isClean);
      builders.set(index, builder);
    }
    return builder.getBuilder();
  }
44860
protected String getSenderEmail(Message mailMessage) throws MessagingException
    {
        Address[] addresses=mailMessage.getFrom();
        String senderEmail=null;
        if((addresses!=null)&&(addresses.length>0))
        {
            //get sender mail address (only first from is used)
            Address address=addresses[0];
            
            //get as string
            senderEmail=address.toString();
        }

        return senderEmail;
    }
90947
protected String createExceptionMessage(final String message, final Object... messageParameters) {

        if (ArrayUtils.isEmpty(messageParameters)) {
            return message;
        } else {
            return String.format(message, messageParameters);
        }
    }
1326872
public BaseMessage processMessage(BaseMessage message)
    {
        if (message == null)
            return null;
        this.updateLogFiles(message, true);  // Need to change log status to SENTOK (also associate return message log trx ID) (todo)
        String strReturnQueueName = null;
        if (message.getMessageHeader() instanceof TrxMessageHeader)
            strReturnQueueName = (String)((TrxMessageHeader)message.getMessageHeader()).getMessageHeaderMap().get(MessageConstants.RETURN_QUEUE_NAME);
        if (strReturnQueueName == null)
            strReturnQueueName = MessageConstants.TRX_RETURN_QUEUE;
        TrxMessageHeader privateMessageHeader = new TrxMessageHeader(strReturnQueueName, MessageConstants.INTERNET_QUEUE, null);
        if (message.getMessageHeader().getRegistryIDMatch() == null)
        {   // The registry is probably in the message header
            Integer intRegistryID = this.getRegistryID(message);
            if (intRegistryID != null)
                message.getMessageHeader().setRegistryIDMatch(intRegistryID);
        }
        privateMessageHeader.setRegistryIDMatch(message.getMessageHeader().getRegistryIDMatch());
        message.setMessageHeader(privateMessageHeader);

        Environment env = null;
        if ((this.getTask() != null)
            && (this.getTask().getApplication() != null))
                env = ((BaseApplication)this.getTask().getApplication()).getEnvironment();
        if (env == null)
            env = Environment.getEnvironment(null);
        App app = null;
        if (this.getTask() != null)
        	app = this.getTask().getApplication();
        MessageManager msgManager = env.getMessageManager(app, true);
        msgManager.sendMessage(message);
        return null;
    }
243774
public String checkMessagingConnectionForTheDm( String message )
	throws DebugWsException {

		this.logger.finer( "Checking messaging connection with the DM: message=" + message );

		WebResource path = this.resource.path( UrlConstants.DEBUG ).path( "check-dm" );
		if( message != null )
			path = path.queryParam( "message", message );

		ClientResponse response = this.wsClient.createBuilder( path ).get( ClientResponse.class );
		if( Family.SUCCESSFUL != response.getStatusInfo().getFamily()) {
			String value = response.getEntity( String.class );
			this.logger.finer( response.getStatusInfo() + ": " + value );
			throw new DebugWsException( response.getStatusInfo().getStatusCode(), value );
		}

		this.logger.finer( String.valueOf( response.getStatusInfo()));
		return response.getEntity( String.class );
	}
761200
public int handleMessage(BaseMessage message)
    {
        Map<String,Object> properties = new HashMap<String,Object>();
        String strMessageType =  (String)message.get(MessageConstants.MESSAGE_TYPE_PARAM);
        String strStartIndex = (String)message.get(START_INDEX_PARAM);
        String strEndIndex = (String)message.get(END_INDEX_PARAM);
        if (strMessageType != null)
            properties.put(MessageConstants.MESSAGE_TYPE_PARAM, strMessageType);
        if (strStartIndex != null)
            properties.put(START_INDEX_PARAM, strStartIndex);
        if (strEndIndex != null)
            properties.put(END_INDEX_PARAM, strEndIndex);
        Map<String,Object> propertiesHdr = null;
        if (message.getMessageHeader() != null)
            propertiesHdr = message.getMessageHeader().getProperties();
        if (propertiesHdr != null)
            properties.putAll(propertiesHdr); // Merge them to simplify access
        if (properties != null)
        {
            strMessageType =  (String)properties.get(MessageConstants.MESSAGE_TYPE_PARAM);
            try {
                int iMessageType = Integer.parseInt(strMessageType);
                if ((Constants.AFTER_ADD_TYPE == iMessageType)
                    || (Constants.AFTER_DELETE_TYPE == iMessageType)
                    || (Constants.AFTER_UPDATE_TYPE == iMessageType))
                {
                    SwingUtilities.invokeLater(new UpdateGridTable(properties));
                }
            } catch (NumberFormatException ex) {
                // Ignore
            }
        }
        return super.handleMessage(message);
    }