Writes a WBS entity to the PM XML file.

@param mpxj MPXJ Task entity
519332
private void writeWBS(Task mpxj)
   {
      if (mpxj.getUniqueID().intValue() != 0)
      {
         WBSType xml = m_factory.createWBSType();
         m_project.getWBS().add(xml);
         String code = mpxj.getWBS();
         code = code == null || code.length() == 0 ? DEFAULT_WBS_CODE : code;

         Task parentTask = mpxj.getParentTask();
         Integer parentObjectID = parentTask == null ? null : parentTask.getUniqueID();

         xml.setCode(code);
         xml.setGUID(DatatypeConverter.printUUID(mpxj.getGUID()));
         xml.setName(mpxj.getName());

         xml.setObjectId(mpxj.getUniqueID());
         xml.setParentObjectId(parentObjectID);
         xml.setProjectObjectId(PROJECT_OBJECT_ID);
         xml.setSequenceNumber(Integer.valueOf(m_wbsSequence++));

         xml.setStatus("Active");
      }

      writeChildTasks(mpxj);
   }
852480
private void writeTask(Task task) throws IOException
   {
      writeFields(null, task, TaskField.values());
      for (Task child : task.getChildTasks())
      {
         writeTask(child);
      }
   }
1246354
@Override
    public void writeXML(XMLOutput xmlOutput) throws IOException {
        xmlOutput.startTag("FindBugsProfile");
        xmlOutput.stopTag(false);
        TreeSet<Class<?>> treeSet = new TreeSet<>(new TotalTimeComparator(this));
        treeSet.addAll(profile.keySet());
        long totalTime = 0;
        for (Profile p : profile.values()) {
            totalTime += p.totalTime.get();
        }

        long accumulatedTime = 0;

        for (Class<?> c : treeSet) {
            Profile p = getProfile(c);
            if (p == null) {
                continue;
            }
            p.writeXML(xmlOutput);
            accumulatedTime += p.totalTime.get();
            if (accumulatedTime > 3 * totalTime / 4) {
                break;
            }
        }
        xmlOutput.closeTag("FindBugsProfile");
    }
345711
private void writeAssignmentTimephasedData(ResourceAssignment mpx, Project.Assignments.Assignment xml)
   {
      if (m_writeTimphasedData && mpx.getHasTimephasedData())
      {
         List<TimephasedDataType> list = xml.getTimephasedData();
         ProjectCalendar calendar = mpx.getCalendar();
         BigInteger assignmentID = xml.getUID();

         List<TimephasedWork> complete = mpx.getTimephasedActualWork();
         List<TimephasedWork> planned = mpx.getTimephasedWork();

         if (m_splitTimephasedAsDays)
         {
            TimephasedWork lastComplete = null;
            if (complete != null && !complete.isEmpty())
            {
               lastComplete = complete.get(complete.size() - 1);
            }

            TimephasedWork firstPlanned = null;
            if (planned != null && !planned.isEmpty())
            {
               firstPlanned = planned.get(0);
            }

            if (planned != null)
            {
               planned = splitDays(calendar, mpx.getTimephasedWork(), null, lastComplete);
            }

            if (complete != null)
            {
               complete = splitDays(calendar, complete, firstPlanned, null);
            }
         }

         if (planned != null)
         {
            writeAssignmentTimephasedData(assignmentID, list, planned, 1);
         }

         if (complete != null)
         {
            writeAssignmentTimephasedData(assignmentID, list, complete, 2);
         }
      }
   }
1075071
public XML write(){
		try { FilesManager.write(xmlJmapper, xmlPath);
		} catch (IOException e) {JmapperLog.error(e);}
		return this;
	}
1107803
private void writeWorkWeeks(Project.Calendars.Calendar xmlCalendar, ProjectCalendar mpxjCalendar)
   {
      List<ProjectCalendarWeek> weeks = mpxjCalendar.getWorkWeeks();
      if (!weeks.isEmpty())
      {
         WorkWeeks xmlWorkWeeks = m_factory.createProjectCalendarsCalendarWorkWeeks();
         xmlCalendar.setWorkWeeks(xmlWorkWeeks);
         List<WorkWeek> xmlWorkWeekList = xmlWorkWeeks.getWorkWeek();

         for (ProjectCalendarWeek week : weeks)
         {
            WorkWeek xmlWeek = m_factory.createProjectCalendarsCalendarWorkWeeksWorkWeek();
            xmlWorkWeekList.add(xmlWeek);

            xmlWeek.setName(week.getName());
            TimePeriod xmlTimePeriod = m_factory.createProjectCalendarsCalendarWorkWeeksWorkWeekTimePeriod();
            xmlWeek.setTimePeriod(xmlTimePeriod);
            xmlTimePeriod.setFromDate(week.getDateRange().getStart());
            xmlTimePeriod.setToDate(week.getDateRange().getEnd());

            WeekDays xmlWeekDays = m_factory.createProjectCalendarsCalendarWorkWeeksWorkWeekWeekDays();
            xmlWeek.setWeekDays(xmlWeekDays);

            List<Project.Calendars.Calendar.WorkWeeks.WorkWeek.WeekDays.WeekDay> dayList = xmlWeekDays.getWeekDay();

            for (int loop = 1; loop < 8; loop++)
            {
               DayType workingFlag = week.getWorkingDay(Day.getInstance(loop));

               if (workingFlag != DayType.DEFAULT)
               {
                  Project.Calendars.Calendar.WorkWeeks.WorkWeek.WeekDays.WeekDay day = m_factory.createProjectCalendarsCalendarWorkWeeksWorkWeekWeekDaysWeekDay();
                  dayList.add(day);
                  day.setDayType(BigInteger.valueOf(loop));
                  day.setDayWorking(Boolean.valueOf(workingFlag == DayType.WORKING));

                  if (workingFlag == DayType.WORKING)
                  {
                     Project.Calendars.Calendar.WorkWeeks.WorkWeek.WeekDays.WeekDay.WorkingTimes times = m_factory.createProjectCalendarsCalendarWorkWeeksWorkWeekWeekDaysWeekDayWorkingTimes();
                     day.setWorkingTimes(times);
                     List<Project.Calendars.Calendar.WorkWeeks.WorkWeek.WeekDays.WeekDay.WorkingTimes.WorkingTime> timesList = times.getWorkingTime();

                     ProjectCalendarHours bch = week.getCalendarHours(Day.getInstance(loop));
                     if (bch != null)
                     {
                        for (DateRange range : bch)
                        {
                           if (range != null)
                           {
                              Project.Calendars.Calendar.WorkWeeks.WorkWeek.WeekDays.WeekDay.WorkingTimes.WorkingTime time = m_factory.createProjectCalendarsCalendarWorkWeeksWorkWeekWeekDaysWeekDayWorkingTimesWorkingTime();
                              timesList.add(time);

                              time.setFromTime(range.getStart());
                              time.setToTime(range.getEnd());
                           }
                        }
                     }
                  }
               }
            }
         }
      }
   }
629054
private void writeXML(String xml) {
        String resourceName = System.getProperty(CONFIG_FILENAME_KEY);
        if (resourceName == null) {
            return;
        } else {
            URL rUrl = ClassLoader.getSystemResource(resourceName);
            if (rUrl != null) {
                File file = new File(rUrl.getFile());
                if (file != null && file.canWrite()) {
                    FileWriter fw = null;
                    try {
                        fw = new FileWriter(file);
                        fw.write(xml);
                        fw.close();
                    } catch (IOException ioe) {
                        //@TODO log it?
                    } finally {
                        try {
                            fw.close();
                        } catch (IOException ioee) {
                            ; //Nothing to do.
                        }
                        fw = null;
                        file = null;
                    }
                }
            }
        }
    }
300409
private void writePageAndReport(CmsXmlPage page, boolean report) throws CmsException {

        CmsFile file = page.getFile();
        byte[] content = page.marshal();
        file.setContents(content);
        // check lock
        CmsLock lock = getCms().getLock(file);
        if (lock.isNullLock() || lock.isOwnedBy(getCms().getRequestContext().getCurrentUser())) {
            // lock the page
            checkLock(getCms().getSitePath(file));
            // write the file with the new content
            getCms().writeFile(file);
            // unlock the page
            getCms().unlockResource(getCms().getSitePath(file));
            if (report) {
                m_report.println(
                    Messages.get().container(Messages.RPT_ELEM_RENAME_2, getParamOldElement(), getParamNewElement()),
                    I_CmsReport.FORMAT_OK);
            }
        }
    }
916284
private void writeTaskExtendedAttributes(Project.Tasks.Task xml, Task mpx)
   {
      Project.Tasks.Task.ExtendedAttribute attrib;
      List<Project.Tasks.Task.ExtendedAttribute> extendedAttributes = xml.getExtendedAttribute();

      for (TaskField mpxFieldID : getAllTaskExtendedAttributes())
      {
         Object value = mpx.getCachedValue(mpxFieldID);

         if (FieldTypeHelper.valueIsNotDefault(mpxFieldID, value))
         {
            m_extendedAttributesInUse.add(mpxFieldID);

            Integer xmlFieldID = Integer.valueOf(MPPTaskField.getID(mpxFieldID) | MPPTaskField.TASK_FIELD_BASE);

            attrib = m_factory.createProjectTasksTaskExtendedAttribute();
            extendedAttributes.add(attrib);
            attrib.setFieldID(xmlFieldID.toString());
            attrib.setValue(DatatypeConverter.printExtendedAttribute(this, value, mpxFieldID.getDataType()));
            attrib.setDurationFormat(printExtendedAttributeDurationFormat(value));
         }
      }
   }
42245
public void save(final XmlWriter w) throws KNXMLException
	{
		/* XML layout:
		 <datapoint stateBased=[true|false] name=string mainNumber=int dptID=string
		 priority=string>
		 knxAddress
		 ...
		 </datapoint>
		*/
		w.writeStartElement(TAG_DATAPOINT);
		w.writeAttribute(ATTR_STATEBASED, Boolean.toString(stateBased));
		w.writeAttribute(ATTR_NAME, name);
		w.writeAttribute(ATTR_MAINNUMBER, Integer.toString(mainNo));
		w.writeAttribute(ATTR_DPTID, dptId == null ? "" : dptId);
		w.writeAttribute(ATTR_PRIORITY, priority.toString());
		main.save(w);
		doSave(w);
		w.writeEndElement();
	}
495325
public static void writeMapToXML(final Map<URI, Set<URI>> m, final File outputFile) throws IOException {
        if (m == null) {
            return;
        }
        final Properties prop = new Properties();
        for (final Map.Entry<URI, Set<URI>> entry: m.entrySet()) {
            final URI key = entry.getKey();
            final String value = StringUtils.join(entry.getValue(), COMMA);
            prop.setProperty(key.getPath(), value);
        }
        try (OutputStream os = new FileOutputStream(outputFile)) {
            prop.storeToXML(os, null);
        } catch (final IOException e) {
            throw new IOException("Failed to write subject scheme graph: " + e.getMessage(), e);
        }
    }
114164
private void writeResource(Resource mpxj)
   {
      ResourceType xml = m_factory.createResourceType();
      m_apibo.getResource().add(xml);

      xml.setAutoComputeActuals(Boolean.TRUE);
      xml.setCalculateCostFromUnits(Boolean.TRUE);
      xml.setCalendarObjectId(getCalendarUniqueID(mpxj.getResourceCalendar()));
      xml.setCurrencyObjectId(DEFAULT_CURRENCY_ID);
      xml.setDefaultUnitsPerTime(Double.valueOf(1.0));
      xml.setEmailAddress(mpxj.getEmailAddress());
      xml.setGUID(DatatypeConverter.printUUID(mpxj.getGUID()));
      xml.setId(RESOURCE_ID_PREFIX + mpxj.getUniqueID());
      xml.setIsActive(Boolean.TRUE);
      xml.setMaxUnitsPerTime(getPercentage(mpxj.getMaxUnits()));
      xml.setName(mpxj.getName());
      xml.setObjectId(mpxj.getUniqueID());
      xml.setParentObjectId(mpxj.getParentID());
      xml.setResourceNotes(mpxj.getNotes());
      xml.setResourceType(getResourceType(mpxj));
      xml.getUDF().addAll(writeUDFType(FieldTypeClass.RESOURCE, mpxj));
   }
585508
private void writeCalendars() throws JAXBException
   {
      //
      // Create the new Planner calendar list
      //
      Calendars calendars = m_factory.createCalendars();
      m_plannerProject.setCalendars(calendars);
      writeDayTypes(calendars);
      List<net.sf.mpxj.planner.schema.Calendar> calendar = calendars.getCalendar();

      //
      // Process each calendar in turn
      //
      for (ProjectCalendar mpxjCalendar : m_projectFile.getCalendars())
      {
         net.sf.mpxj.planner.schema.Calendar plannerCalendar = m_factory.createCalendar();
         calendar.add(plannerCalendar);
         writeCalendar(mpxjCalendar, plannerCalendar);
      }
   }
109943
private void writeResources()
   {
      Resources resources = m_factory.createResources();
      m_plannerProject.setResources(resources);
      List<net.sf.mpxj.planner.schema.Resource> resourceList = resources.getResource();
      for (Resource mpxjResource : m_projectFile.getResources())
      {
         net.sf.mpxj.planner.schema.Resource plannerResource = m_factory.createResource();
         resourceList.add(plannerResource);
         writeResource(mpxjResource, plannerResource);
      }
   }
927276
public void simpleFastWrite(Writer out)
            throws IOException, XmlModelWriterException
    {
        out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
        
        if (_publicID != null && _systemID != null) {
            out.write("<!DOCTYPE ");
            out.write(_rootName);
            out.write(" PUBLIC \"");
            out.write(_publicID);
            out.write("\" \"");
            out.write(_systemID);
            out.write("\">\n");
        }
        
        writeElement(out, _doc.getDocumentElement(), 0);
    }
362763
@Override public void write(ProjectFile projectFile, OutputStream out) throws IOException
   {
      m_projectFile = projectFile;
      m_eventManager = projectFile.getEventManager();

      m_writer = new PrintStream(out); // the print stream class is the easiest way to create a text file
      m_buffer = new StringBuilder();

      try
      {
         write(); // method call a method, this is how MPXJ is structured, so I followed the lead?
      }

      //      catch (Exception e)
      //      { // used during console debugging
      //         System.out.println("Caught Exception in SDEFWriter.java");
      //         System.out.println(" " + e.toString());
      //      }

      finally
      { // keeps things cool after we're done
         m_writer = null;
         m_projectFile = null;
         m_buffer = null;
      }
   }
1027218
private void writeTasks() throws IOException
   {
      writeAttributeTypes("task_types", TaskField.values());

      m_writer.writeStartList("tasks");
      for (Task task : m_projectFile.getChildTasks())
      {
         writeTask(task);
      }
      m_writer.writeEndList();
   }