Adds markers to a file based on the result. if errors occurred the problem markers are first cleared.

@param file
the file where the markers should be set
@param result
the result indicating if parse errors occurred
@param content
@throws CoreException
350592
private void setFileMarkers(IFile file, ParseResult result)
			throws CoreException
	{
		if (file != null)
		{
			FileUtility.deleteMarker(file, IMarker.PROBLEM, ICoreConstants.PLUGIN_ID);
			if (result.hasParseErrors())
			{
				file.deleteMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
				int previousErrorNumber = -1;
				for (VDMError error : result.getErrors())
				{
					if (previousErrorNumber == error.number)
					{// this check is
						// done to avoid
						// error fall
						// through
						continue;
					} else
					{
						previousErrorNumber = error.number;
					}

					FileUtility.addMarker(file, error.toProblemString(), error.location, IMarker.SEVERITY_ERROR, ICoreConstants.PLUGIN_ID, -1);
				}
			}

			IVdmProject vdmProject = (IVdmProject) project.getAdapter(IVdmProject.class);

			if (result.getWarnings().size() > 0 && vdmProject != null
					&& vdmProject.hasSuppressWarnings())
			{
				for (VDMWarning warning : result.getWarnings())
				{
					FileUtility.addMarker(file, warning.toProblemString(), warning.location, IMarker.SEVERITY_WARNING, ICoreConstants.PLUGIN_ID, -1);
				}
			}
		}

	}
557717
public synchronized static void append(File file,String content) throws IOException {
        Writer writer = writerCache.getOrDefault(file.getPath(), new FileWriter(file,true));
        writer.write(content);
        writer.flush();
        writerCache.put(file.getPath(), writer);
    }
505045
public void registerFileResource(final String file) {
        try {
            _resourceMap.put(file, new File(file).toURI().toURL());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
1329375
public static void writeToFile(@NonNull File file, @NonNull String content) throws IOException {
    OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
    try {
      writer.write(content);
      writer.flush();
    } catch (IOException ioe) {
      Log.e(LOG_TAG, ioe.toString());
    } finally {
      try {
        writer.close();
      } catch (IOException ioe) {
        Log.e(LOG_TAG, ioe.toString());
      }
    }
  }
317861
private void writeFileByte(byte[] content, File file) throws IOException {

        FileOutputStream fOut = null;
        DataOutputStream dOut = null;
        try {
            // write the content to the file in server filesystem
            fOut = new FileOutputStream(file);
            dOut = new DataOutputStream(fOut);
            dOut.write(content);
            dOut.flush();
        } catch (IOException e) {
            throw e;
        } finally {
            try {
                if (fOut != null) {
                    fOut.close();
                }
            } catch (IOException e) {
                // ignore
            }
            try {
                if (dOut != null) {
                    dOut.close();
                }
            } catch (IOException e) {
                // ignore
            }
        }
    }
602383
public void put(String url, String result) {
        if (TextUtils.isEmpty(url)) {
            return;
        }

        ContentValues contentValues = new ContentValues();
        contentValues.put(OfflinerDBHelper.REQUEST_RESULT, result);
        contentValues.put(OfflinerDBHelper.REQUEST_URL, url);
        contentValues.put(OfflinerDBHelper.REQUEST_TIMESTAMP, Calendar.getInstance().getTime().getTime());

        this.startQuery(
                TOKEN_CHECK_SAVED_STATUS,
                contentValues,
                getUri(OfflinerDBHelper.TABLE_CACHE),
                OfflinerDBHelper.PARAMS_CACHE,
                OfflinerDBHelper.REQUEST_URL + " = '" + url + "'",
                null,
                null
        );
    }
785634
public static void writeFile(final File file, final FileOutput output, final IProgressMonitor monitor) throws CoreException {
        try (FileOutputStream fout = new FileOutputStream(file);
                BufferedOutputStream bout = new BufferedOutputStream(fout)) {
            if (monitor != null) {
                monitor.subTask("writing data to " + file.getName());
            }
            output.writeFile(bout);
            bout.flush();
        } catch (IOException e) {
            IStatus status = FindbugsPlugin.createErrorStatus("Exception while " + output.getTaskDescription(), e);
            throw new CoreException(status);
        }
    }
1280412
public static void setContentTypeHeader(HttpResponse response, File file) {
		String mimeType = MimeTypes.getMimeTypeForFileName(file.getName());
		String mimeFinal = mimeType != null ? mimeType : MimeTypes.getDefaultMimeType();
		response.headers().set(CONTENT_TYPE, mimeFinal);
	}
636274
public void writeContent(final OutputStream result) throws IOException
    {
        this.font.writeBegin(result);
        writeFieldBegin(result);
        writeFieldInstBegin(result);
        writeFieldInstContent(result);
        writeFieldInstEnd(result);
        writeFieldResultBegin(result);
        writeFieldResultContent(result);
        writeFieldResultEnd(result);
        writeFieldEnd(result);
        this.font.writeEnd(result);
    }
92736
@Override
    public void setContent(final InputStream content, final String contentType,
                           final Collection<URI> checksums, final String originalFileName,
                           final StoragePolicyDecisionPoint storagePolicyDecisionPoint)
            throws UnsupportedOperationException {
        throw new UnsupportedOperationException(
                "Cannot call setContent() on local file, call setExternalContent() instead");
    }
1076671
public void writeContent(final OutputStream result) throws IOException
    {
        if(!inHeader) {
            if(this.offset != -1) {
                result.write(RtfFont.FONT_SIZE);
                result.write(intToByteArray(this.offset));
            }
            result.write(RtfParagraph.PARAGRAPH);
        }
        
        for(int i = 0; i < this.rows.size(); i++) {
        	RtfElement re = (RtfElement)this.rows.get(i);
            //.result.write(re.write());
        	re.writeContent(result);
        }
        
        result.write(RtfParagraph.PARAGRAPH_DEFAULTS);
    }
54003
public static void saveFile(final File file, final String contents, final String encoding) throws IOException {
        saveFile(file, contents.getBytes(encoding));
    }
1370268
public void addFilePart(final String fieldName, final InputStream stream, final String contentType)
        throws IOException
    {
        addFilePart(fieldName, stream, null, contentType);
    }
21341
public void writeContent(final OutputStream result) throws IOException
    {
    	writeRowDefinition(result);
        
        for(int i = 0; i < this.cells.size(); i++) {
            RtfCell rtfCell = (RtfCell) this.cells.get(i);
            rtfCell.writeContent(result);
        }

        result.write(DELIMITER);

        if(this.document.getDocumentSettings().isOutputTableRowDefinitionAfter()) {
        	writeRowDefinition(result);
        }

        result.write(ROW_END);
        this.document.outputDebugLinebreak(result);
    }
1267980
public void set(ResultItem item){
        try {
            if (item.getValueType() == ValueType.DOCUMENT) {
                content = item.asString().getBytes("UTF-8");
                contentType = ContentType.XML;
            } else if (item.getValueType() == ValueType.ELEMENT) {
                content = item.asString().getBytes("UTF-8");
                contentType = ContentType.XML;
            } else if (item.getValueType() == ValueType.TEXT) {
                content = item.asString().getBytes("UTF-8");
                contentType = ContentType.TEXT;
            } else if (item.getValueType() == ValueType.BINARY) {
                if (item.isCached()) {
                    content = ((XdmBinary) item.getItem()).asBinaryData();
                } else {
                    is = item.asInputStream();
                }
                contentType = ContentType.BINARY;
            } else if (item.getValueType() == ValueType.ARRAY_NODE ||
                item.getValueType() == ValueType.BOOLEAN_NODE ||
                item.getValueType() == ValueType.NULL_NODE ||
                item.getValueType() == ValueType.NUMBER_NODE ||
                item.getValueType() == ValueType.OBJECT_NODE) {
                content = item.asString().getBytes("UTF-8");
                contentType = ContentType.JSON;
            } else {
                contentType = ContentType.UNKNOWN;
            }
        } catch (UnsupportedEncodingException e) {
            LOG.error(e);
        }
    }
730637
public static void setFileData(final File file, final byte[] fileData, final String contentType) throws FrameworkException, IOException {
		FileHelper.setFileData(file, fileData, contentType, true);
	}
1114804
public void setFile(File file) {
		if(file != null) {
			this.file = file;
			
			// Replace the label by the file's name.
			this.setLabel(file.getName());
			
			// Change the icon, depending if the file is a folder or not.
			this.updateIcon();
		}
	}