Dump argument components to String. Can be also used outside UIMA pipeline.

@param jCas jcas
@return string dump
559733
public static String dumpArguments(JCas jCas, boolean includeProperties, boolean includeRelations)
    {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        PrintStream out = new PrintStream(outputStream);

        String documentId = DocumentMetaData.get(jCas).getDocumentId();

        out.println("======== #" + documentId + " begin ==========================");

        Collection<ArgumentComponent> argumentComponents = JCasUtil
                .select(jCas, ArgumentComponent.class);

        out.println("----------------- ArgumentComponent -----------------");
        out.println("# of argument units: " + argumentComponents.size());

        for (ArgumentComponent argumentComponent : argumentComponents) {
            out.println(argumentUnitToString(argumentComponent));

            if (includeProperties) {
                out.println(formatProperties(argumentComponent));
            }

            if (argumentComponent instanceof Claim) {
                Claim claim = (Claim) argumentComponent;
                String stance = claim.getStance();

                if (stance != null) {
                    out.println("Stance: " + stance);
                }
            }
        }

        Collection<ArgumentRelation> argumentRelations = JCasUtil
                .select(jCas, ArgumentRelation.class);

        if (includeRelations) {
            out.println("----------------- ArgumentRelation -----------------");
            out.println("# of argument relations: " + argumentRelations.size());

            for (ArgumentRelation argumentRelation : argumentRelations) {
                out.println(argumentRelation.getType().getShortName());
                out.println("   source: " + argumentUnitToString(
                        argumentRelation.getSource()));
                out.println("   target: " + argumentUnitToString(
                        argumentRelation.getTarget()));

                if (includeProperties) {
                    out.println(formatProperties(argumentRelation));
                }
            }
        }

        out.println("======== #" + documentId + " end ==========================");

        try {
            return outputStream.toString("utf-8");
        }
        catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }
350098
public static String dumpAsString(
                                      Object obj)
    {
        if (obj instanceof DERObject)
        {
            return _dumpAsString("", (DERObject) obj);
        }
        else if (obj instanceof DEREncodable)
        {
            return _dumpAsString("", ((DEREncodable) obj).getDERObject());
        }

        return "unknown object type " + obj.toString();
    }
361307
private void dumpUsefulStuff(IncidentStream is, Object[] objs) {

    // The first parameter is a marker telling us what sort of data we have in subsequent
    // parameters.
    if (objs != null && objs.length > 0) {
      if (objs[0] == MfpConstants.DM_BUFFER && objs.length >= 4)
        dumpJmfBuffer(is, (byte[])objs[1], ((Integer)objs[2]).intValue(), ((Integer)objs[3]).intValue());
      else if (objs[0] == MfpConstants.DM_MESSAGE && objs.length >= 2)
        dumpJmfMessage(is, (JMFMessage)objs[1], objs[2]);
      else if (objs[0] == MfpConstants.DM_SLICES && objs.length >= 2)
        dumpJmfSlices(is, (List<DataSlice>)objs[1]);
    }

  }
769559
String[] getJavaSystemPropertiesArguments() throws IOException {
        LOGGER.entering();
        List<String> args = new LinkedList<>();

        // Next, FWD all JVM -D args to the child process
        args.addAll(Arrays.asList(getPresentJavaSystemPropertiesArguments()));

        // Setup logging for child process
        args.addAll(Arrays.asList(getLoggingSystemPropertiesArguments()));

        LOGGER.exiting(args.toString());
        return args.toArray(new String[args.size()]);
    }
1087971
public static void toJSONString(OutputAccessor out, Map<String, ? extends Object> map) {

        writeObjectStart(out);
        boolean first = true;

        for (Map.Entry<String, ? extends Object> entry : map.entrySet()) {

            if (first) {
                first = false;
            } else {
                writeKeyValueSeparator(out);
            }

            writeMapEntry(out, entry.getKey(), entry.getValue());
        }

        writeObjectEnd(out);

    }
1359733
static void dumpConfig(final String name, final Config config, final PrintWriter printWriter) {

        if (printWriter == null) {
            throw new IllegalArgumentException("writer argument cannot be null");
        }

        printWriter.println();
        printWriter.println("^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^  ^");
        printWriter.println(name + " " + config.root().origin());
        printWriter.println(config.root().render(configRenderOptions));
        printWriter.flush();
    }
1044563
protected StringBuilder dumpParameters(StringBuilder sb) {
        sb.append("sslEnabled=").append(sslEnabled);
        sb.append(", sslKeystoreFile='").append(sslKeystoreFile).append('\'');
        sb.append(", sslTruststoreFile='").append(sslTruststoreFile).append('\'');
        sb.append(", sslKeystorePassword=").append(sslKeystorePassword != null && !sslKeystorePassword.isEmpty());
        sb.append(", sslTruststorePassword=").append(sslTruststorePassword != null && !sslTruststorePassword.isEmpty());
        sb.append(", sslKeystore=").append(sslKeystore);
        sb.append(", sslTruststore=").append(sslTruststore);
        sb.append(", bootstrapHttpEnabled=").append(bootstrapHttpEnabled);
        sb.append(", bootstrapCarrierEnabled=").append(bootstrapCarrierEnabled);
        sb.append(", bootstrapHttpDirectPort=").append(bootstrapHttpDirectPort);
        sb.append(", bootstrapHttpSslPort=").append(bootstrapHttpSslPort);
        sb.append(", bootstrapCarrierDirectPort=").append(bootstrapCarrierDirectPort);
        sb.append(", bootstrapCarrierSslPort=").append(bootstrapCarrierSslPort);
        sb.append(", ioPoolSize=").append(ioPoolSize);
        sb.append(", computationPoolSize=").append(computationPoolSize);
        sb.append(", responseBufferSize=").append(responseBufferSize);
        sb.append(", requestBufferSize=").append(requestBufferSize);
        sb.append(", kvServiceEndpoints=").append(kvServiceEndpoints);
        sb.append(", viewServiceEndpoints=").append(viewServiceEndpoints);
        sb.append(", queryServiceEndpoints=").append(queryServiceEndpoints);
        sb.append(", searchServiceEndpoints=").append(searchServiceEndpoints);
        sb.append(", configPollInterval=").append(configPollInterval);
        sb.append(", configPollFloorInterval=").append(configPollFloorInterval);
        sb.append(", networkResolution=").append(networkResolution);
        sb.append(", ioPool=").append(ioPool.getClass().getSimpleName());
        if (ioPoolShutdownHook == null || ioPoolShutdownHook instanceof  NoOpShutdownHook) {
            sb.append("!unmanaged");
        }
        if (kvIoPool != null) {
            sb.append(", kvIoPool=").append(kvIoPool.getClass().getSimpleName());
            if (kvIoPoolShutdownHook == null || kvIoPoolShutdownHook instanceof  NoOpShutdownHook) {
                sb.append("!unmanaged");
            }
        } else {
            sb.append(", kvIoPool=").append("null");
        }
        if (viewIoPool != null) {
            sb.append(", viewIoPool=").append(viewIoPool.getClass().getSimpleName());
            if (viewIoPoolShutdownHook == null || viewIoPoolShutdownHook instanceof  NoOpShutdownHook) {
                sb.append("!unmanaged");
            }
        } else {
            sb.append(", viewIoPool=").append("null");
        }
        if (searchIoPool != null) {
            sb.append(", searchIoPool=").append(searchIoPool.getClass().getSimpleName());
            if (searchIoPoolShutdownHook == null || searchIoPoolShutdownHook instanceof  NoOpShutdownHook) {
                sb.append("!unmanaged");
            }
        } else {
            sb.append(", searchIoPool=").append("null");
        }
        if (queryIoPool != null) {
            sb.append(", queryIoPool=").append(queryIoPool.getClass().getSimpleName());
            if (queryIoPoolShutdownHook == null || queryIoPoolShutdownHook instanceof  NoOpShutdownHook) {
                sb.append("!unmanaged");
            }
        } else {
            sb.append(", queryIoPool=").append("null");
        }
        if (analyticsIoPool != null) {
            sb.append(", analyticsIoPool=").append(analyticsIoPool.getClass().getSimpleName());
            if (analyticsIoPoolShutdownHook == null || analyticsIoPoolShutdownHook instanceof  NoOpShutdownHook) {
                sb.append("!unmanaged");
            }
        } else {
            sb.append(", analyticsIoPool=").append("null");
        }

        sb.append(", coreScheduler=").append(coreScheduler.getClass().getSimpleName());
        if (coreSchedulerShutdownHook == null || coreSchedulerShutdownHook instanceof NoOpShutdownHook) {
            sb.append("!unmanaged");
        }
        sb.append(", memcachedHashingStrategy=").append(memcachedHashingStrategy.getClass().getSimpleName());
        sb.append(", eventBus=").append(eventBus.getClass().getSimpleName());
        sb.append(", packageNameAndVersion=").append(packageNameAndVersion);
        sb.append(", retryStrategy=").append(retryStrategy);
        sb.append(", maxRequestLifetime=").append(maxRequestLifetime);
        sb.append(", retryDelay=").append(retryDelay);
        sb.append(", reconnectDelay=").append(reconnectDelay);
        sb.append(", observeIntervalDelay=").append(observeIntervalDelay);
        sb.append(", keepAliveInterval=").append(keepAliveInterval);
        sb.append(", continuousKeepAliveEnabled=").append(continuousKeepAliveEnabled);
        sb.append(", keepAliveErrorThreshold=").append(keepAliveErrorThreshold);
        sb.append(", keepAliveTimeout=").append(keepAliveTimeout);
        sb.append(", autoreleaseAfter=").append(autoreleaseAfter);
        sb.append(", bufferPoolingEnabled=").append(bufferPoolingEnabled);
        sb.append(", tcpNodelayEnabled=").append(tcpNodelayEnabled);
        sb.append(", mutationTokensEnabled=").append(mutationTokensEnabled);
        sb.append(", socketConnectTimeout=").append(socketConnectTimeout);
        sb.append(", callbacksOnIoPool=").append(callbacksOnIoPool);
        sb.append(", disconnectTimeout=").append(disconnectTimeout);
        sb.append(", requestBufferWaitStrategy=").append(requestBufferWaitStrategy);
        sb.append(", certAuthEnabled=").append(certAuthEnabled);
        sb.append(", coreSendHook=").append(couchbaseCoreSendHook == null ? "null" :
            couchbaseCoreSendHook.getClass().getSimpleName());
        sb.append(", forceSaslPlain=").append(forceSaslPlain);
        sb.append(", compressionMinRatio=").append(minCompressionRatio);
        sb.append(", compressionMinSize=").append(minCompressionSize);
        sb.append(", compressionEnabled=").append(compressionEnabled);
        sb.append(", operationTracingEnabled=").append(operationTracingEnabled);
        sb.append(", operationTracingServerDurationEnabled=").append(operationTracingServerDurationEnabled);
        sb.append(", tracer=").append(tracer != null ? tracer.getClass().getSimpleName() : "null");
        sb.append(", orphanResponseReportingEnabled=").append(orphanResponseReportingEnabled);
        sb.append(", orphanResponseReporter=").append(orphanResponseReporter != null ? orphanResponseReporter.getClass().getSimpleName() : "null");
        sb.append(", keyValueServiceConfig=").append(keyValueServiceConfig);
        sb.append(", queryServiceConfig=").append(queryServiceConfig);
        sb.append(", searchServiceConfig=").append(searchServiceConfig);
        sb.append(", viewServiceConfig=").append(viewServiceConfig);
        sb.append(", analyticsServiceConfig=").append(analyticsServiceConfig);
        return sb;
    }
701993
@Override
    public String asString(Properties properties) {
        try {
            return super.asString(properties);
        } catch (TransformerException e) {
            throw wrapExceptionAsRuntimeException(e);
        }
    }
1335568
public static String dumpModules(List<Module> modules) {
        final StringBuilder sb = new StringBuilder(4028);
        sb.append("\n--------Modules(Total ").append(modules.size()).append(")--------");
        sb.append("\n");
        for (int i = 0; i < modules.size(); i++) {
            final Module module = modules.get(i);
            sb.append("module ").append(i + 1).append(":");
            sb.append("\n\tmappingPath='").append(module.getMappingPath());
            sb.append("';\n\tpackageRelativePath='").append(module.getRelativePath());
            sb.append("';\n\turl='").append(module.getUrl());
            sb.append("';\n\tcontrollers=[");
            final List<ControllerRef> controllerMappings = module.getControllers();

            for (final ControllerRef controller : controllerMappings) {
                sb.append("'").append(Arrays.toString(controller.getMappingPaths())).append("'=")
                        .append(controller.getControllerClass().getSimpleName()).append(", ");
            }
            if (!controllerMappings.isEmpty()) {
                sb.setLength(sb.length() - 2);
            }
            sb.append("];\n\tparamResolvers=[");
            for (ParamResolver resolver : module.getCustomerResolvers()) {
                sb.append(resolver.getClass().getSimpleName()).append(", ");
            }
            if (module.getCustomerResolvers().size() > 0) {
                sb.setLength(sb.length() - 2);
            }
            sb.append("];\n\tvalidators=[");
            for (ParamValidator validator : module.getValidators()) {
                sb.append(validator.getClass().getSimpleName()).append(", ");
            }
            if (module.getValidators().size() > 0) {
                sb.setLength(sb.length() - 2);
            }
            sb.append("];\n\tinterceptors=[");
            for (InterceptorDelegate interceptor : module.getInterceptors()) {
                sb.append(interceptor.getName()).append("(").append(interceptor.getPriority())
                        .append("), ");
            }
            if (module.getInterceptors().size() > 0) {
                sb.setLength(sb.length() - 2);
            }
            sb.append("];\n\terrorHander=").append(
                    module.getErrorHandler() == null ? "<null>" : module.getErrorHandler());
            sb.append("\n\n");
        }
        sb.append("--------end--------");
        return sb.toString();
    }
74597
public static boolean hasWebArgumentMetadata(final JCas jCas)
    {
        FSIterator<FeatureStructure> iterator = jCas.getCas().getIndexRepository().getAllIndexedFS(
                CasUtil.getType(jCas.getCas(), WebArgumentMetadata.class));

        return iterator.hasNext();
    }
562793
private String getComponentType(String componentType) throws SignatureException {

        String JVMSig = "";

        if(componentType != null){
            switch (componentType) {
                case "void":    JVMSig += SIG_VOID;    break;
                case "boolean": JVMSig += SIG_BOOLEAN; break;
                case "byte":    JVMSig += SIG_BYTE;    break;
                case "char":    JVMSig += SIG_CHAR;    break;
                case "short":   JVMSig += SIG_SHORT;   break;
                case "int":     JVMSig += SIG_INT;     break;
                case "long":    JVMSig += SIG_LONG;    break;
                case "float":   JVMSig += SIG_FLOAT;   break;
                case "double":  JVMSig += SIG_DOUBLE;  break;
                default:
                    if (!componentType.equals("")) {
                        TypeElement classNameDoc = elems.getTypeElement(componentType);

                        if (classNameDoc == null) {
                            throw new SignatureException(componentType);
                        }
                        else {
                            String classname = classNameDoc.getQualifiedName().toString();
                            String newclassname = classname.replace('.', '/');
                            JVMSig += "L";
                            JVMSig += newclassname;
                            JVMSig += ";";
                        }
                    }
                    break;
            }
        }
        return JVMSig;
    }
49794
public String jsComponentNames() {

        StringBuffer jsCode = new StringBuffer(1024);
        jsCode.append("\t// an array from 1...n holding the component names\n");
        jsCode.append("\tvar componentNames = new Array(");
        jsCode.append(m_components.elementList().size());
        jsCode.append(");\n");
        for (int i = 0; i < m_components.elementList().size(); i++) {
            CmsSetupComponent component = m_components.elementList().get(i);
            jsCode.append("\tcomponentNames[" + i + "] = \"" + component.getId() + "\";\n");
        }
        jsCode.append("\n\n");
        return jsCode.toString();
    }
634717
protected void assembleArguments()
            throws MojoExecutionException {
        if (XhasMember) {
            ajcOptions.add("-XhasMember");
        }

        // Add classpath
        ajcOptions.add("-classpath");
        ajcOptions.add(AjcHelper.createClassPath(project, null, getClasspathDirectories()));

        // Add boot classpath
        if (null != bootclasspath) {
            ajcOptions.add("-bootclasspath");
            ajcOptions.add(bootclasspath);
        }

        if (null != Xjoinpoints) {
            ajcOptions.add("-Xjoinpoints:" + Xjoinpoints);
        }

        // Add warn option
        if (null != warn) {
            ajcOptions.add("-warn:" + warn);
        }

        if (null != proc) {
            ajcOptions.add("-proc:" + proc);
        }

        if (Xset != null && !Xset.isEmpty()) {
            StringBuilder sb = new StringBuilder("-Xset:");
            for (Map.Entry<String, String> param : Xset.entrySet()) {
                sb.append(param.getKey());
                sb.append("=");
                sb.append(param.getValue());
                sb.append(',');
            }
            ajcOptions.add(sb.substring(0, sb.length() - 1));
        }

        // Add artifacts or directories to weave
        String joinedWeaveDirectories = null;
        if (weaveDirectories != null) {
            joinedWeaveDirectories = StringUtils.join(weaveDirectories, File.pathSeparator);
        }
        addModulesArgument("-inpath", ajcOptions, weaveDependencies, joinedWeaveDirectories,
                "dependencies and/or directories to weave");

        // Add library artifacts
        addModulesArgument("-aspectpath", ajcOptions, aspectLibraries, getAdditionalAspectPaths(),
                "an aspect library");

        // Add xmlConfigured option and argument
        if (null != xmlConfigured) {
            ajcOptions.add("-xmlConfigured");
            ajcOptions.add(xmlConfigured.getAbsolutePath());
        }

        // add target dir argument
        ajcOptions.add("-d");
        ajcOptions.add(getOutputDirectory().getAbsolutePath());

        ajcOptions.add("-s");
        ajcOptions.add(getGeneratedSourcesDirectory().getAbsolutePath());

        // Add all the files to be included in the build,
        if (null != ajdtBuildDefFile) {
            resolvedIncludes = AjcHelper.getBuildFilesForAjdtFile(ajdtBuildDefFile, basedir);
        } else {
            resolvedIncludes = getIncludedSources();
        }
        ajcOptions.addAll(resolvedIncludes);
    }
368516
public static String buildToString(Object... params) {
		StringBuffer finalMessage = new StringBuffer();
		int i = 0;
		for (Object object : params) {
			if (i++ > 0) {
				finalMessage.append(FIELD_SEPARATOR);
			}
			if (object instanceof List<?>) {
				finalMessage.append(JKCollectionUtil.toString((List<?>) object));
			} else {
				finalMessage.append(JKObjectUtil.toString(object, true));
			}
		}
		String fullText = finalMessage.toString();
		return fullText;
	}
211569
public void process(JCas jcas) throws AnalysisEngineProcessException {
		// if the annotate_tokens flag is set, annotate the tokens and add them to the jcas
		if(annotate_tokens)
			if(language.equals(Language.CHINESE))
				tokenizeChinese(jcas); // chinese needs different tokenization
			else
				tokenize(jcas);

		/* if the annotate_partofspeech flag is set, annotate partofspeech and,
		 * if specified, also tag sentences based upon the partofspeech tags. 
		 */
		if(annotate_partofspeech) 
			doTreeTag(jcas);
		
		// if the improve_german_sentences flag is set, improve the sentence tokens made by the treetagger
		if(this.language == Language.GERMAN)
			improveGermanSentences(jcas);
		
		// if French, improve the sentence tokens made by the TreeTagger with settings for French
		if (this.language == Language.FRENCH)
			improveFrenchSentences(jcas);
		
	}
1045768
private void doTreeTag(JCas jcas) {
		try {
			if(ttProc == null) {
				ttProc = new TreeTaggerProcess(ttprops.getTreeTaggingProcess());
			}
			
			Logger.printDetail(component, "TreeTagger (pos tagging) with: " + ttprops.parFileName);
			
			AnnotationIndex ai = jcas.getAnnotationIndex(Token.type);
			List<String> tokenStrings = new ArrayList<>();
			List<Token> tokens = new ArrayList<>();
			for(FSIterator fsi = ai.iterator(); fsi.hasNext();) {
				Token token = (Token) fsi.next();
				tokenStrings.add(token.getCoveredText());
				tokens.add(token);
			}
			
			ttreader = new TreeTaggerReader(tokens, ttProc.getStdout(), jcas, annotate_sentences);
			ttwriter = new TreeTaggerWriter(tokenStrings, ttProc.getStdin());
			
			Thread rThread = new Thread(ttreader);
			Thread wThread = new Thread(ttwriter);
			
			rThread.start();
			wThread.start();
			
			rThread.join();
			wThread.join();
		} catch(IOException | InterruptedException e) {
			e.printStackTrace();
		}
	}
654181
private void tokenize(JCas jcas) {
		// read tokenized text to add tokens to the jcas
		Logger.printDetail(component, "TreeTagger (tokenization) with: " + ttprops.abbFileName);
		
		EnumSet<Flag> flags = Flag.getSet(ttprops.languageSwitch);
		TreeTaggerTokenizer ttt; ttprops.abbFileName = "english-abbreviations";
		if(ttprops.abbFileName != null) {
			ttt = new TreeTaggerTokenizer(ttprops.rootPath + ttprops.fileSeparator + "lib" + ttprops.fileSeparator + ttprops.abbFileName, flags);
		} else {
			ttt = new TreeTaggerTokenizer(null, flags);
		}
		
		String docText = jcas.getDocumentText().replaceAll("\n\n", "\nEMPTYLINE\n");
		List<String> tokenized = ttt.tokenize(docText);
		
		int tokenOffset = 0;
		// loop through all the lines in the treetagger output
		for(String s : tokenized) {
			// charset missmatch fallback: signal (invalid) s
			if ((!(s.equals("EMPTYLINE"))) && (jcas.getDocumentText().indexOf(s, tokenOffset) < 0)) {
				Logger.printError(component, "Tokenization was interrupted because the token \"" + s 
						+ "\" could not be found in the original text. The reason for this might be "
						+ "that the encoding of the document is not UTF-8. This token was skipped and "
						+ "if it was part of a temporal expression, will not be extracted.");
				continue;
			}
			// create tokens and add them to the jcas's indexes.
			Token newToken = new Token(jcas);
			if (s.equals("EMPTYLINE")){
				newToken.setBegin(tokenOffset);
				newToken.setEnd(tokenOffset);
				newToken.setPos("EMPTYLINE");
				if (annotate_partofspeech){
					newToken.addToIndexes();
				}
			}
			else{
				newToken.setBegin(jcas.getDocumentText().indexOf(s, tokenOffset));
				newToken.setEnd(newToken.getBegin() + s.length());
				newToken.addToIndexes();
				tokenOffset = newToken.getEnd();
			}
		}
	}