/* (non-Javadoc)
@see tuwien.auto.calimero.mgmt.ManagementClient#writeProperty
(tuwien.auto.calimero.mgmt.Destination, int, int, int, int, byte[])
545442
public void writeProperty(Destination dst, int objIndex, int propID, int start,
		int elements, byte[] data) throws KNXTimeoutException, KNXRemoteException,
		KNXDisconnectException, KNXLinkClosedException
	{
		if (objIndex < 0 || objIndex > 255 || propID < 0 || propID > 255 || start < 0
			|| start > 0xFFF || data.length == 0 || elements < 0 || elements > 15)
			throw new KNXIllegalArgumentException("argument value out of range");
		final byte[] asdu = new byte[4 + data.length];
		asdu[0] = (byte) objIndex;
		asdu[1] = (byte) propID;
		asdu[2] = (byte) ((elements << 4) | ((start >>> 8) & 0xF));
		asdu[3] = (byte) start;
		for (int i = 0; i < data.length; ++i)
			asdu[4 + i] = data[i];
		final byte[] send = DataUnitBuilder.createAPDU(PROPERTY_WRITE, asdu);
		final byte[] apdu = sendWait2(dst, priority, send, PROPERTY_RESPONSE, 4, 14);
		// if number of elements is 0, remote app had problems
		final int elems = (apdu[4] & 0xFF) >> 4;
		if (elems == 0)
			throw new KNXRemoteException("property write failed/forbidden");
		if (elems != elements)
			throw new KNXInvalidResponseException("number of elements differ");
		if (data.length != apdu.length - 6)
			throw new KNXInvalidResponseException("data lengths differ, bytes: "
				+ data.length + " written, " + (apdu.length - 6) + " response");
		// explicitly read back written properties
		for (int i = 4; i < asdu.length; ++i)
			if (apdu[2 + i] != asdu[i])
				throw new KNXRemoteException("read back failed (erroneous property data)");
	}
674924
void encodeProperty(ByteArrayOutputStream baos, Object value) throws JMSException {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "encodeProperty", new Object[]{baos, value});

    // The value should be a non-null String
    if (value instanceof String) {

      baos.write(encodedName, 0, encodedName.length);            // Write out the encoded tname

      String strVal = (String)value;
      int len = Utf8Codec.getEncodedLength(strVal);
      byte[] buffer = new byte[len + ArrayUtil.SHORT_SIZE];     // bytes for the value length & the value itself
      ArrayUtil.writeShort(buffer, 0, (short)len);              // Encode in the length of the String value
      Utf8Codec.encode(buffer, ArrayUtil.SHORT_SIZE, strVal); // Encode in the String value itself

      baos.write(buffer, 0, buffer.length);                     // Write the encode value to the buffer
    }

    // If it is not a String, something has gone horribly wrong
    else {
      throw (JMSException)JmsErrorUtils.newThrowable(JMSException.class
                                                    ,"INTERNAL_ERROR_CWSIA0362"
                                                    ,new Object[] {"ShortStringPropertyCoder.encodeProperty#1", longName, value}
                                                    ,null
                                                    ,"ShortStringPropertyCoder.encodeProperty#1"
                                                    ,null
                                                    ,tc);
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "encodeProperty");
  }
842085
public void write(byte[] b, int off, int len) throws IOException
	{
		//PK89810, If WCCustomProperties.FINISH_RESPONSE_ON_CLOSE is set and stream is already obtained and closed. 
		// User will not be allowed to write more data if the above case is met, outputstreamClosed will be true and default is false.
		if (!(WCCustomProperties.FINISH_RESPONSE_ON_CLOSE) || !outputstreamClosed ) //PK89810
		{
		if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) {  //306998.15
			logger.logp(Level.FINE, CLASS_NAME,"write", "write len --> "+len);
        }
		if (len < 0)
		{
			logger.logp(Level.SEVERE, CLASS_NAME,"write", "Illegal.Argument.Trying.to.write.chars");
			throw new IllegalArgumentException();
		}
		if (!_hasWritten && obs != null)
		{
			_hasWritten = true;
			if (obsList!=null){
				for (int i=0;i<obsList.size();i++){
					obsList.get(i).alertFirstWrite();
				}
			}
			else {
			obs.alertFirstWrite();
		}
		}
		if (limit > -1)
		{
			if (total + len > limit)
			{
				len = limit - total;
				except = new WriteBeyondContentLengthException();
			}
		}
		if (len >= buf.length)
		{
			response.setFlushMode(false);
			flushBytes();
			total += len;
			writeOut(b, off, len);
			response.setFlushMode(true);
			check();
			return;
		}
		int avail = buf.length - count;
		if (len > avail)
		{
			response.setFlushMode(false);
			flushBytes();
			response.setFlushMode(true);
		}
		System.arraycopy(b, off, buf, count, len);
		count += len;
		total += len;
		check();
	}
		else
		{//PK89810 start
			if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE))
				logger.logp(Level.FINE, CLASS_NAME,"write", "write bytes not allowed, outputstreamClosed value --> " + outputstreamClosed);			
		}//PK89810 End
	}
835089
@Override
	public final void setObjectProperty(String name, Object value) throws JMSException
    {
        if (value == null)
            throw new MessageFormatException("A property value cannot be null");
            
        // Check type
        if (!(value instanceof Boolean ||
              value instanceof Byte ||
              value instanceof Short ||
              value instanceof Integer ||
              value instanceof Long ||
              value instanceof Float ||
              value instanceof Double ||
              value instanceof String))
            throw new MessageFormatException("Unsupported property value type : "+value.getClass().getName());
        
        setProperty(name,value);
    }
699
private void addProperty(XMLStreamWriter writer, String name, Class<?> propertyType, String readMethod, String writeMethod) throws XMLStreamException
   {
      if (name.length() != 0)
      {
         writer.writeStartElement("property");

         // convert property name to .NET style (i.e. first letter uppercase)
         String propertyName = name.substring(0, 1).toUpperCase() + name.substring(1);
         writer.writeAttribute("name", propertyName);

         String type = getTypeString(propertyType);

         writer.writeAttribute("sig", "()" + type);
         if (readMethod != null)
         {
            writer.writeStartElement("getter");
            writer.writeAttribute("name", readMethod);
            writer.writeAttribute("sig", "()" + type);
            writer.writeEndElement();
         }
         if (writeMethod != null)
         {
            writer.writeStartElement("setter");
            writer.writeAttribute("name", writeMethod);
            writer.writeAttribute("sig", "(" + type + ")V");
            writer.writeEndElement();
         }

         writer.writeEndElement();
      }
   }
438042
public void setPropertyDestinationType(Class<?> clazz, String propertyName,
			TypeReference<?> destinationType) {
		propertiesDestinationTypes.put(new ClassProperty(clazz, propertyName), destinationType);
	}
257333
@Override
	public void writeByte(byte value) throws JMSException
    {
        try
        {
            getOutput().writeByte(value);
        }
        catch (IOException e)
        {
            throw new FFMQException("Cannot write message body","IO_ERROR",e);
        }
    }
967404
private void writeProjectProperties()
   {
      ProjectProperties properties = m_projectFile.getProjectProperties();

      m_plannerProject.setCompany(properties.getCompany());
      m_plannerProject.setManager(properties.getManager());
      m_plannerProject.setName(getString(properties.getName()));
      m_plannerProject.setProjectStart(getDateTime(properties.getStartDate()));
      m_plannerProject.setCalendar(getIntegerString(m_projectFile.getDefaultCalendar().getUniqueID()));
      m_plannerProject.setMrprojectVersion("2");
   }
890389
@Override
    public void writeSasFileProperties(SasFileProperties sasFileProperties) throws IOException {
        constructPropertiesString("Bitness: ", sasFileProperties.isU64() ? "x64" : "x86");
        constructPropertiesString("Compressed: ", sasFileProperties.getCompressionMethod());
        constructPropertiesString("Endianness: ", sasFileProperties.getEndianness() == 1 ? "LITTLE_ENDIANNESS"
                : "BIG_ENDIANNESS");
        constructPropertiesString("Encoding: ", sasFileProperties.getEncoding());
        constructPropertiesString("Name: ", sasFileProperties.getName());
        constructPropertiesString("File type: ", sasFileProperties.getFileType());
        constructPropertiesString("File label: ", sasFileProperties.getFileLabel());
        constructPropertiesString("Date created: ", sasFileProperties.getDateCreated());
        constructPropertiesString("Date modified: ", sasFileProperties.getDateModified());
        constructPropertiesString("SAS release: ", sasFileProperties.getSasRelease());
        constructPropertiesString("SAS server type: ", sasFileProperties.getServerType());
        constructPropertiesString("OS name: ", sasFileProperties.getOsName());
        constructPropertiesString("OS type: ", sasFileProperties.getOsType());
        constructPropertiesString("Header Length: ", sasFileProperties.getHeaderLength());
        constructPropertiesString("Page Length: ", sasFileProperties.getPageLength());
        constructPropertiesString("Page Count: ", sasFileProperties.getPageCount());
        constructPropertiesString("Row Length: ", sasFileProperties.getRowLength());
        constructPropertiesString("Row Count: ", sasFileProperties.getRowCount());
        constructPropertiesString("Mix Page Row Count: ", sasFileProperties.getMixPageRowCount());
        constructPropertiesString("Columns Count: ", sasFileProperties.getColumnsCount());
        getWriter().flush();
    }
1302519
@Override
    public synchronized void write(byte[] b, int off, int len) throws IOException {
        super.write(b, off, len);
        this.branch.write(b, off, len);
    }
979603
private void writeConfToFile(File dir, Map<PropertyKey, String> properties) throws IOException {
    // Generates the full set of properties to write
    Map<PropertyKey, String> map = new HashMap<>(mProperties);
    for (Map.Entry<PropertyKey, String> entry : properties.entrySet()) {
      map.put(entry.getKey(), entry.getValue());
    }

    StringBuilder sb = new StringBuilder();
    for (Entry<PropertyKey, String> entry : map.entrySet()) {
      sb.append(String.format("%s=%s%n", entry.getKey(), entry.getValue()));
    }

    dir.mkdirs();
    try (FileOutputStream fos
        = new FileOutputStream(new File(dir, "alluxio-site.properties"))) {
      fos.write(sb.toString().getBytes(Charsets.UTF_8));
    }
  }
194239
public void writePropertyObject(String resourcename, CmsProperty property) throws CmsException {

        CmsResource resource = readResource(resourcename, CmsResourceFilter.IGNORE_EXPIRATION);
        getResourceType(resource).writePropertyObject(this, m_securityManager, resource, property);
    }
1145809
@Override
	public void writeObject(Object value) throws JMSException
    {
        if (value == null)
            throw new NullPointerException(); // [JMS Spec]
        
        if (value instanceof Boolean)
            writeBoolean(((Boolean)value).booleanValue());
        else
        if (value instanceof Byte)
            writeByte(((Byte)value).byteValue());
        else
        if (value instanceof Short)
            writeShort(((Short)value).shortValue());
        else
        if (value instanceof Integer)
            writeInt(((Integer)value).intValue());
        else
        if (value instanceof Long)
            writeLong(((Long)value).longValue());
        else
        if (value instanceof Float)
            writeFloat(((Float)value).floatValue());
        else
        if (value instanceof Double)
            writeDouble(((Double)value).doubleValue());
        else
        if (value instanceof String)
            writeUTF((String)value);
        else
        if (value instanceof byte[])
            writeBytes((byte[])value);
        else
            throw new MessageFormatException("Unsupported property value type : "+value.getClass().getName());
    }
694355
void write(ObjectOutputStream out) throws IOException {
        PutField fields = out.putFields();

        fields.put(CONTEXT, threadContextDescriptor.serialize());

        fields.put(EXEC_PROPS, threadContextDescriptor.getExecutionProperties());

        fields.put(INTERNAL_PROP_NAMES, internalPropNames);

        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        ObjectOutputStream oout = new ObjectOutputStream(bout);
        oout.writeObject(object);
        oout.flush();
        fields.put(OBJECT, bout.toByteArray());
        oout.close();

        out.writeFields();
    }
644992
protected void writeContainerProperties(Map<String, String> properties) throws IOException {

        if (properties.size() > 0) {

            writer.append("[cols=\"2*\", options=\"header\"]").append(NEW_LINE);
            writer.append(".").append(this.resourceBundle.getString("asciidoc.reporter.properties")).append(NEW_LINE);
            writer.append("|===").append(NEW_LINE).append(NEW_LINE);
            writer.append("|KEY").append(NEW_LINE);
            writer.append("|VALUE").append(NEW_LINE).append(NEW_LINE);

            Set<Entry<String, String>> entrySet = properties.entrySet();

            for (Entry<String, String> entry : entrySet) {
                writer.append("|").append(entry.getKey()).append(NEW_LINE);
                writer.append("|").append(entry.getValue()).append(NEW_LINE).append(NEW_LINE);
            }

            writer.append("|===").append(NEW_LINE).append(NEW_LINE);
        }

    }
594641
protected void writeProperties(List<PropertyEntry> propertyEntries) throws IOException {

        if (containsAnyKeyValueEntryOrFileEntry(propertyEntries)) {

            writer.append("[cols=\"2*\", options=\"header\"]").append(NEW_LINE);
            writer.append(".").append(this.resourceBundle.getString("asciidoc.reporter.properties")).append(NEW_LINE);
            writer.append("|===").append(NEW_LINE).append(NEW_LINE);
            writer.append("|KEY").append(NEW_LINE);
            writer.append("|VALUE").append(NEW_LINE).append(NEW_LINE);

            writePropertiesRows(propertyEntries);

            writer.append("|===").append(NEW_LINE).append(NEW_LINE);
        }

        writeTables(propertyEntries);
    }
1206200
private function writeProperty(
        PropertyInterface $property,
        PropertyInterface $blockProperty,
        $value,
        $index,
        NodeInterface $node,
        $userId,
        $webspaceKey,
        $languageCode,
        $segmentKey,
        $isImport = false
    ) {
        // save sub property
        $contentType = $this->contentTypeManager->get($property->getContentTypeName());
        $blockPropertyWrapper = new BlockPropertyWrapper($property, $blockProperty, $index);
        $blockPropertyWrapper->setValue($value);

        if ($isImport && $contentType instanceof ContentTypeExportInterface) {
            return $contentType->importData(
                new SuluNode($node),
                $blockPropertyWrapper,
                $value,
                $userId,
                $webspaceKey,
                $languageCode,
                $segmentKey
            );
        }

        $contentType->write(
            new SuluNode($node),
            $blockPropertyWrapper,
            $userId,
            $webspaceKey,
            $languageCode,
            $segmentKey
        );
    }