Search in sources :

Example 61 with MessageFormat

use of java.text.MessageFormat in project translationstudio8 by heartsome.

the class SaxonSearcher method getPropagateTranslationsRowIds.

/**
	 * 得到所有需要繁殖翻译的文本段的rowId,用于繁殖翻译 robert 2012-04-03	//UNDO 这里还没有完善,因为text()后还有多个空格的情况,见Bug #2279。
	 * @param xliffXmlnsMap
	 * @param langFilterCondition
	 * @return ;
	 * @throws XQException 
	 */
public static Map<String, List<String>> getPropagateTranslationsRowIds(Map<String, String> xliffXmlnsMap, String langFilterCondition) throws XQException {
    if (xliffXmlnsMap == null || xliffXmlnsMap.isEmpty()) {
        return null;
    }
    StringBuffer querySB = new StringBuffer();
    // 声明部分
    String declare = "";
    // 所有命名空间和别名的映射
    HashMap<String, String> nsAliasMap = new HashMap<String, String>();
    if (xliffXmlnsMap != null && !xliffXmlnsMap.isEmpty()) {
        HashSet<String> set = new HashSet<String>(xliffXmlnsMap.values());
        int i = 0;
        for (String ns : set) {
            if (ns == null || "".equals(ns)) {
                continue;
            }
            declare += "declare namespace ns" + i + "='" + ns + "'; ";
            nsAliasMap.put(ns, "ns" + i);
            i++;
        }
    }
    HashMap<String, String> fileURIs = new HashMap<String, String>();
    for (String fileName : xliffXmlnsMap.keySet()) {
        fileURIs.put(fileName, new File(fileName).toURI().getPath().replace("'", "''"));
    }
    if (langFilterCondition == null || "".equals(langFilterCondition)) {
        langFilterCondition = "";
    } else {
        langFilterCondition = "[" + langFilterCondition + "]";
    }
    String queryString1 = "";
    String queryString2 = "";
    List<String> args;
    MessageFormat messageFormat1;
    MessageFormat messageFormat2;
    int i = 0;
    for (String fileName : fileURIs.keySet()) {
        //{1}
        String varFile = "$file" + i;
        //{2}
        String varTU = "$tu" + i;
        String namespace = xliffXmlnsMap.get(fileName);
        // 命名空间别名	{4}
        String nsAlias = nsAliasMap.get(namespace);
        if (nsAlias == null) {
            nsAlias = "";
        }
        if (!"".equals(nsAlias)) {
            nsAlias += ":";
        }
        //查询出源文与译文不为空,并且未加锁状态的所有节点的rowid
        String message1 = "for {1} in doc(\''{0}'')/{4}xliff/{4}file{3}, {2} in {1}/{4}body//{4}trans-unit[({4}source/text()!='''' or {4}source/*) and ({4}target/text()!='''') and not(@translate=''no'')] \n" + "return <tu fileName=''{0}'' original='''{'{1}/@original'}''' tuid='''{'{2}/@id'}''' source='''{'{2}/{4}source/text()'}''' /> " + (i == fileURIs.size() - 1 ? "\n" : ", \n");
        String message2 = "for {1} in doc(\''{0}'')/{4}xliff/{4}file{3}, {2} in {1}/{4}body//{4}trans-unit[({4}source/text()!='''' or {4}source/*) and not({4}target/text()!='''') and not(@translate=''no'')] \n" + "return <tu fileName=''{0}'' original='''{'{1}/@original'}''' tuid='''{'{2}/@id'}''' source='''{'{2}/{4}source/text()'}''' /> " + (i == fileURIs.size() - 1 ? "\n" : ", \n");
        messageFormat1 = new MessageFormat(message1);
        messageFormat2 = new MessageFormat(message2);
        args = new ArrayList<String>(Arrays.asList(fileURIs.get(fileName), varFile, varTU, langFilterCondition, nsAlias));
        queryString1 += messageFormat1.format(args.toArray(new String[] {}));
        queryString2 += messageFormat2.format(args.toArray(new String[] {}));
        i++;
    }
    querySB.append(declare + "\n");
    querySB.append("let $matchTU := (");
    querySB.append(queryString1 + ")\n");
    querySB.append("let $matchedTU := (");
    querySB.append(queryString2 + ")\n");
    //下面是测试部份了
    //		querySB.append("for $rootTU in $matchedTU return <root fileName='{$rootTU/@fileName}' original='{$rootTU/@original}' tuid='{$rootTU/@tuid}' />");
    querySB.append("for $rootTU in $matchTU return <root fileName='{$rootTU/@fileName}' original='{$rootTU/@original}' tuid='{$rootTU/@tuid}'>{ \n");
    querySB.append("for $tu in $matchedTU \n");
    querySB.append("return if($rootTU/@source=$tu/@source) then <tu fileName='{$tu/@fileName}' original='{$tu/@original}' tuid='{$tu/@tuid}' />  else '' \n");
    querySB.append("}</root>");
    System.out.println("querySB.toString() = " + querySB.toString());
    return PropagateQurey(querySB.toString());
}
Also used : MessageFormat(java.text.MessageFormat) HashMap(java.util.HashMap) File(java.io.File) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 62 with MessageFormat

use of java.text.MessageFormat in project spring-framework by spring-projects.

the class StaticMessageSource method resolveCode.

@Override
protected MessageFormat resolveCode(String code, Locale locale) {
    String key = code + '_' + locale.toString();
    String msg = this.messages.get(key);
    if (msg == null) {
        return null;
    }
    synchronized (this.cachedMessageFormats) {
        MessageFormat messageFormat = this.cachedMessageFormats.get(key);
        if (messageFormat == null) {
            messageFormat = createMessageFormat(msg, locale);
            this.cachedMessageFormats.put(key, messageFormat);
        }
        return messageFormat;
    }
}
Also used : MessageFormat(java.text.MessageFormat)

Example 63 with MessageFormat

use of java.text.MessageFormat in project antlrworks by antlr.

the class XJLocalizable method getStringFormat.

public static String getStringFormat(String s, Object[] args) {
    MessageFormat formatter = new MessageFormat("");
    formatter.setLocale(Locale.getDefault());
    formatter.applyPattern(getXJString(s));
    return formatter.format(args);
}
Also used : MessageFormat(java.text.MessageFormat)

Example 64 with MessageFormat

use of java.text.MessageFormat in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class StoreStatsService method getFormatRuntime.

private String getFormatRuntime() {
    final long millisecond = 1;
    final long second = 1000 * millisecond;
    final long minute = 60 * second;
    final long hour = 60 * minute;
    final long day = 24 * hour;
    final MessageFormat messageFormat = new MessageFormat("[ {0} days, {1} hours, {2} minutes, {3} seconds ]");
    long time = System.currentTimeMillis() - this.messageStoreBootTimestamp;
    long days = time / day;
    long hours = (time % day) / hour;
    long minutes = (time % hour) / minute;
    long seconds = (time % minute) / second;
    return messageFormat.format(new Long[] { days, hours, minutes, seconds });
}
Also used : MessageFormat(java.text.MessageFormat)

Example 65 with MessageFormat

use of java.text.MessageFormat in project webofneeds by researchstudio-sat.

the class BATestScriptListener method rememberConnectionURI.

private void rememberConnectionURI(final URI needURI, final URI connectionURI) {
    if (this.coordinatorURI.equals(needURI)) {
        this.coordinatorSideConnectionURI = connectionURI;
        addConnectionURIToFilter(connectionURI);
    } else if (this.participantURI.equals(needURI)) {
        this.participantSideConnectionURI = connectionURI;
        addConnectionURIToFilter(connectionURI);
    } else {
        throw new IllegalStateException(new MessageFormat("Listener called for need {0}, " + "which is neither my coordinator {1} nor my " + "participant {2}").format(new Object[] { needURI, this.coordinatorURI, this.participantURI }));
    }
}
Also used : MessageFormat(java.text.MessageFormat)

Aggregations

MessageFormat (java.text.MessageFormat)690 LogMessage (org.apache.qpid.server.logging.LogMessage)105 CertificateException (java.security.cert.CertificateException)52 KeyStoreException (java.security.KeyStoreException)48 IOException (java.io.IOException)47 UnrecoverableKeyException (java.security.UnrecoverableKeyException)46 UnrecoverableEntryException (java.security.UnrecoverableEntryException)43 CertStoreException (java.security.cert.CertStoreException)43 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)33 X509Certificate (java.security.cert.X509Certificate)30 ArrayList (java.util.ArrayList)27 ResourceBundle (java.util.ResourceBundle)27 Date (java.util.Date)23 Locale (java.util.Locale)22 File (java.io.File)21 Certificate (java.security.cert.Certificate)19 PrivateKey (java.security.PrivateKey)16 Format (java.text.Format)16 MissingResourceException (java.util.MissingResourceException)16 HashMap (java.util.HashMap)15