当前位置: 首页>>代码示例>>Java>>正文


Java OsUtils类代码示例

本文整理汇总了Java中org.springframework.shell.support.util.OsUtils的典型用法代码示例。如果您正苦于以下问题:Java OsUtils类的具体用法?Java OsUtils怎么用?Java OsUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OsUtils类属于org.springframework.shell.support.util包,在下文中一共展示了OsUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: formatResultForDisplay

import org.springframework.shell.support.util.OsUtils; //导入依赖的package包/类
private String formatResultForDisplay(List<PartialPressuresCalculResult> partialPressuresCalculResults) {

        final StringBuilder result = new StringBuilder();

        for (PartialPressuresCalculResult partialPressuresCalculResult : partialPressuresCalculResults) {

            result
                    .append(partialPressuresCalculResult.getBreathingMix())
                    .append("\t")
                    .append(partialPressuresCalculResult.getDepth().getMeters());

            for (Map.Entry<Gas, Pressure> gasPartialPressure : partialPressuresCalculResult.getPartialPressuresPerGas().entrySet())
                result
                        .append("\t")
                        .append(gasPartialPressure.getKey())
                        .append("\t")
                        .append(new BigDecimal(gasPartialPressure.getValue().getBar()).setScale(2, RoundingMode.HALF_UP).doubleValue());

            result.append(OsUtils.LINE_SEPARATOR);
        }

        return result.toString();
    }
 
开发者ID:UrielSarrazin,项目名称:partial-pressure-calculator,代码行数:24,代码来源:Command.java

示例2: getBanner

import org.springframework.shell.support.util.OsUtils; //导入依赖的package包/类
public String getBanner() {
	StringBuffer buf = new StringBuffer();
	buf.append(OsUtils.LINE_SEPARATOR);
	buf.append("=======================================" + OsUtils.LINE_SEPARATOR);
	buf.append("*                                     *"+ OsUtils.LINE_SEPARATOR);
	buf.append("*            --Jarvis--               *" +OsUtils.LINE_SEPARATOR);
	buf.append("*                                     *"+ OsUtils.LINE_SEPARATOR);
	buf.append("=======================================" + OsUtils.LINE_SEPARATOR);
	buf.append("Version:          " + getVersion() + OsUtils.LINE_SEPARATOR);
	buf.append("Systems:          " + starSystemService.systemCountOrientDb() + OsUtils.LINE_SEPARATOR);
       buf.append("Frameshift Edges: " + starSystemService.shiftCountOrientDb() + OsUtils.LINE_SEPARATOR);
	buf.append("Stations:         " + stationService.stationCountOrientDb() + OsUtils.LINE_SEPARATOR);
       buf.append("Exchanges:        " + tradeService.exchangeCountOrientDb() + OsUtils.LINE_SEPARATOR);
       
	
	return buf.toString();
}
 
开发者ID:jrosocha,项目名称:jarvisCli,代码行数:18,代码来源:JarvisBannerProvider.java

示例3: printStarSystemTable

import org.springframework.shell.support.util.OsUtils; //导入依赖的package包/类
public String printStarSystemTable(StarSystem starSystem) {

        String out = "";
        Date start = new Date();
        List<Station> stations = stationService.getStationsForSystemOrientDb(starSystem.getName());
        List<Map<String, Object>> tableData = stations.stream().map(station -> {
            Map<String, Object> tableRow = new HashMap<>();
            tableRow.put("STATION", station.getName());
            tableRow.put("BLACK MARKET", station.getBlackMarket());
            tableRow.put("DAYS OLD", (new Date().getTime() - station.getDate()) / 1000 / 60 / 60 / 24);
            return tableRow;
        }).collect(Collectors.toList());

        out += OsUtils.LINE_SEPARATOR;
        out += "SYSTEM: " + starSystem.getName() + " @ " + starSystem.getX() + ", " + starSystem.getY() + ", " + starSystem.getZ() + OsUtils.LINE_SEPARATOR;
        out += OsUtils.LINE_SEPARATOR + TableRenderer.renderMapDataAsTable(tableData, ImmutableList.of("STATION", "BLACK MARKET", "DAYS OLD"));
        out += OsUtils.LINE_SEPARATOR + "executed in " + (new Date().getTime() - start.getTime()) / 1000.0 + " seconds.";

        return out;
    }
 
开发者ID:jrosocha,项目名称:jarvisCli,代码行数:21,代码来源:StarSystemService.java

示例4: generateLine

import org.springframework.shell.support.util.OsUtils; //导入依赖的package包/类
protected String generateLine(int maxlineLength, int pad, String message) {
    String out = ""; 
    String padS = "";
    
    for (int i = 0; i < pad; i++) {
        padS += " ";
    }
    
    String messageFormatted = "";
    if (message.length() > maxlineLength) {
        messageFormatted += message.substring(0, maxlineLength);
    } else {
        messageFormatted += message;
        for (int i = 0; i < ((maxlineLength) - message.length()); i++) {
            messageFormatted += " ";
        }
    }
    
    out += "|" + padS + messageFormatted + padS + "|" + OsUtils.LINE_SEPARATOR;
    return out;
}
 
开发者ID:jrosocha,项目名称:jarvisCli,代码行数:22,代码来源:DrawUtils.java

示例5: render

import org.springframework.shell.support.util.OsUtils; //导入依赖的package包/类
@Override
public String render(List<StratioStream> streams) throws ShellException {
    StringBuilder queryTables = new StringBuilder();
    List<Map<String, Object>> data = new ArrayList<>();
    for (StratioStream stratioStream : streams) {
        Map<String, Object> row = new HashMap<>();
        row.put(STREAM_NAME, stratioStream.getStreamName());
        row.put(USER_DEFINED, stratioStream.getUserDefined());
        row.put(QUERIES, stratioStream.getQueries().size());
        row.put(ELEMENTS, stratioStream.getColumns().size());
        row.put(ACTIVE_ACTIONS, stratioStream.getActiveActions().toString());

        queryTables.append(renderQueriesTable(stratioStream.getQueries(), stratioStream.getStreamName()));

        data.add(row);
    }

    StringBuilder result = new StringBuilder();
    result.append(TableRenderer.renderMapDataAsTable(data, columns));
    result.append(OsUtils.LINE_SEPARATOR);
    result.append(queryTables);

    return result.toString();
}
 
开发者ID:Stratio,项目名称:Decision,代码行数:25,代码来源:StreamListRenderer.java

示例6: renderQueriesTable

import org.springframework.shell.support.util.OsUtils; //导入依赖的package包/类
private String renderQueriesTable(List<StreamQuery> queries, String streamName) {
    StringBuilder result = new StringBuilder();
    if (queries != null && queries.size() != 0) {
        List<Map<String, Object>> data = new ArrayList<>();
        for (StreamQuery streamQuery : queries) {
            Map<String, Object> row = new HashMap<>();
            row.put(ID, streamQuery.getQueryId());
            row.put(QUERY_RAW, streamQuery.getQuery());
            data.add(row);
        }
        result.append("Queries from stream ".concat(streamName).concat(":"));
        result.append(OsUtils.LINE_SEPARATOR);
        result.append(OsUtils.LINE_SEPARATOR);
        result.append(TableRenderer.renderMapDataAsTable(data, queryColumns));
        result.append(OsUtils.LINE_SEPARATOR);
    }
    return result.toString();
}
 
开发者ID:Stratio,项目名称:Decision,代码行数:19,代码来源:StreamListRenderer.java

示例7: getBanner

import org.springframework.shell.support.util.OsUtils; //导入依赖的package包/类
@Override
public String getBanner() {
    StringBuilder sb = new StringBuilder();
    sb.append(" _         __  __ _ ");
    sb.append(OsUtils.LINE_SEPARATOR);
    sb.append("| |       / _|/ _(_)");
    sb.append(OsUtils.LINE_SEPARATOR);
    sb.append("| |_ ___ | |_| |_ _ ");
    sb.append(OsUtils.LINE_SEPARATOR);
    sb.append("| __/ _ \\|  _|  _| |");
    sb.append(OsUtils.LINE_SEPARATOR);
    sb.append("| || (_) | | | | | |");
    sb.append(OsUtils.LINE_SEPARATOR);
    sb.append(" \\__\\___/|_| |_| |_|");
    sb.append(OsUtils.LINE_SEPARATOR);
    return sb.toString();
}
 
开发者ID:dzhemriza,项目名称:toffi,代码行数:18,代码来源:BannerProvider.java

示例8: getStyle

import org.springframework.shell.support.util.OsUtils; //导入依赖的package包/类
@CliCommand(value = "style get", help = "Get a style.")
public String getStyle(
        @CliOption(key = "name", mandatory = true, help = "The name") String name,
        @CliOption(key = "workspace", mandatory = false, help = "The workspace") String workspace
) throws Exception {
    String url = geoserver.getUrl() + "/rest";
    if (workspace != null) {
        url += "/workspaces/" + URLUtil.encode(workspace);
    }
    url += "/styles/" + URLUtil.encode(name) + ".xml";
    String xml = HTTPUtils.get(url, geoserver.getUser(), geoserver.getPassword());
    Element element = JDOMBuilder.buildElement(xml);
    StringBuilder builder = new StringBuilder();
    String TAB = "   ";
    builder.append(element.getChildText("name")).append(OsUtils.LINE_SEPARATOR);
    Element sldVersionElement = element.getChild("sldVersion");
    if (sldVersionElement != null) {
        builder.append(TAB).append("SLD Version: ").append(sldVersionElement.getChildText("version")).append(OsUtils.LINE_SEPARATOR);
    }
    builder.append(TAB).append("File Name: ").append(element.getChildText("filename")).append(OsUtils.LINE_SEPARATOR);
    return builder.toString();
}
 
开发者ID:jericks,项目名称:geoserver-shell,代码行数:23,代码来源:StyleCommands.java

示例9: versionList

import org.springframework.shell.support.util.OsUtils; //导入依赖的package包/类
@CliCommand(value = "version list", help = "Get versions.")
public String versionList() throws Exception {
    String TAB = "   ";
    String xml = HTTPUtils.get(geoserver.getUrl() + "/rest/about/versions.xml", geoserver.getUser(), geoserver.getPassword());
    StringBuilder builder = new StringBuilder();
    Element root = JDOMBuilder.buildElement(xml);

    List<Element> resources = root.getChildren("resource");
    for (Element resource : resources) {
        String name = resource.getAttributeValue("name");
        String buildTime = resource.getChildText("Build-Timestamp");
        String gitRevision = resource.getChildText("Git-Revision");
        String version = resource.getChildText("Version");
        builder.append(name).append(OsUtils.LINE_SEPARATOR);
        builder.append(TAB).append("Version: ").append(version).append(OsUtils.LINE_SEPARATOR);
        builder.append(TAB).append("Build Time: ").append(buildTime).append(OsUtils.LINE_SEPARATOR);
        builder.append(TAB).append("Git Revision: ").append(gitRevision).append(OsUtils.LINE_SEPARATOR);
        builder.append(OsUtils.LINE_SEPARATOR);
    }

    return builder.toString();
}
 
开发者ID:jericks,项目名称:geoserver-shell,代码行数:23,代码来源:AboutCommands.java

示例10: manifestGet

import org.springframework.shell.support.util.OsUtils; //导入依赖的package包/类
@CliCommand(value = "manifest get", help = "Get a manifest.")
public String manifestGet(
        @CliOption(key = "name", mandatory = true, help = "The name") String name
) throws Exception {
    String TAB = "   ";
    String xml = HTTPUtils.get(geoserver.getUrl() + "/rest/about/manifests.xml", geoserver.getUser(), geoserver.getPassword());
    StringBuilder builder = new StringBuilder();
    Element root = JDOMBuilder.buildElement(xml);
    List<Element> resources = root.getChildren("resource");
    for (Element resource : resources) {
        String n = resource.getAttributeValue("name");
        if (name.equalsIgnoreCase(n)) {
            builder.append(name).append(OsUtils.LINE_SEPARATOR);
            List<Element> children = resource.getChildren();
            for (Element child : children) {
                builder.append(TAB).append(child.getName()).append(": ").append(child.getTextTrim()).append(OsUtils.LINE_SEPARATOR);
            }
        }
    }
    return builder.toString();
}
 
开发者ID:jericks,项目名称:geoserver-shell,代码行数:22,代码来源:AboutCommands.java

示例11: listLayers

import org.springframework.shell.support.util.OsUtils; //导入依赖的package包/类
@CliCommand(value = "gwc layer list", help = "List GeoWebCache Layers.")
public String listLayers() throws Exception {
    String url = geoserver.getUrl() + "/gwc/rest/layers";
    String xml = HTTPUtils.get(url, geoserver.getUser(), geoserver.getPassword());
    StringBuilder builder = new StringBuilder();
    Element element = JDOMBuilder.buildElement(xml);
    List<String> names = new ArrayList<String>();
    List<Element> layerElements = element.getChildren("layer");
    for (Element layerElement : layerElements) {
        names.add(layerElement.getChildText("name"));
    }
    Collections.sort(names);
    for (String name : names) {
        builder.append(name).append(OsUtils.LINE_SEPARATOR);
    }
    return builder.toString();
}
 
开发者ID:jericks,项目名称:geoserver-shell,代码行数:18,代码来源:GeoWebCacheCommands.java

示例12: list

import org.springframework.shell.support.util.OsUtils; //导入依赖的package包/类
@CliCommand(value = "template list", help = "List templates.")
public String list(
        @CliOption(key = "workspace", mandatory = false, help = "The workspace") String workspace,
        @CliOption(key = "datastore", mandatory = false, help = "The datastore") String datastore,
        @CliOption(key = "featuretype", mandatory = false, help = "The featuretype") String featureType,
        @CliOption(key = "coveragestore", mandatory = false, help = "The coveragestore") String coverageStore,
        @CliOption(key = "coverage", mandatory = false, help = "The coverage") String coverage
) throws Exception {
    StringBuilder urlBuilder = buildUrl(geoserver.getUrl(), workspace, datastore, featureType, coverageStore, coverage);
    urlBuilder.append("/templates.xml");
    String xml = HTTPUtils.get(urlBuilder.toString(), geoserver.getUser(), geoserver.getPassword());
    Element rootElement = JDOMBuilder.buildElement(xml);
    List<Element> templateElements = rootElement.getChildren("template");
    List<String> names = new ArrayList<String>();
    Collections.sort(names);
    for (Element templateElement : templateElements) {
        names.add(templateElement.getChildText("name"));
    }
    StringBuilder builder = new StringBuilder();
    for (String name : names) {
        builder.append(name).append(OsUtils.LINE_SEPARATOR);
    }
    return builder.toString();
}
 
开发者ID:jericks,项目名称:geoserver-shell,代码行数:25,代码来源:TemplateCommands.java

示例13: listSession

import org.springframework.shell.support.util.OsUtils; //导入依赖的package包/类
@CliCommand(value = "scripting session list", help = "List scripting sessions.")
public String listSession(
        @CliOption(key = "ext", mandatory = false, help = "The script extension") String ext
) throws Exception {
    String url = geoserver.getUrl() + "/rest/sessions";
    if (ext != null) {
        url += "/" + URLUtil.encode(ext);
    }
    String result = HTTPUtils.get(url, geoserver.getUser(), geoserver.getPassword());
    JSONObject rootJsonObject = new JSONObject(result);
    JSONArray jsonArray = rootJsonObject.getJSONArray("sessions");
    StringBuilder builder = new StringBuilder();
    for (int i = 0; i < jsonArray.length(); i++) {
        JSONObject jsonObject = jsonArray.getJSONObject(i);
        builder.append(jsonObject.getString("id")).append(" ")
                .append(jsonObject.get("engine"))
                .append(OsUtils.LINE_SEPARATOR);
    }
    return builder.toString();
}
 
开发者ID:jericks,项目名称:geoserver-shell,代码行数:21,代码来源:ScriptCommands.java

示例14: get

import org.springframework.shell.support.util.OsUtils; //导入依赖的package包/类
@CliCommand(value = "coverage store get", help = "Get a coverage store.")
public String get(
        @CliOption(key = "workspace", mandatory = true, help = "The workspace") String workspace,
        @CliOption(key = "coveragestore", mandatory = true, help = "The coveragestore") String coveragestore
) throws Exception {
    String url = geoserver.getUrl() + "/rest/workspaces/" + URLUtil.encode(workspace) + "/coveragestores/" + URLUtil.encode(coveragestore) + ".xml";
    String xml = HTTPUtils.get(url, geoserver.getUser(), geoserver.getPassword());
    Element coverageStoreElement = JDOMBuilder.buildElement(xml);
    String name = coverageStoreElement.getChildText("name");
    String type = coverageStoreElement.getChildText("type");
    String enabled = coverageStoreElement.getChildText("enabled");
    String covUrl = coverageStoreElement.getChildText("url");
    // @TODO RESTCoverageStore doesn't have access to type, enabled
    /*GeoServerRESTReader reader = new GeoServerRESTReader(geoserver.getUrl(), geoserver.getUser(), geoserver.getPassword());
    RESTCoverageStore store = reader.getCoverageStore(workspace, coveragestore);*/
    String TAB = "   ";
    StringBuilder builder = new StringBuilder();
    builder.append(name).append(OsUtils.LINE_SEPARATOR);
    builder.append(TAB).append("Type: ").append(type).append(OsUtils.LINE_SEPARATOR);
    builder.append(TAB).append("URL: ").append(covUrl).append(OsUtils.LINE_SEPARATOR);
    builder.append(TAB).append("Enabled: ").append(enabled).append(OsUtils.LINE_SEPARATOR);
    return builder.toString();
}
 
开发者ID:jericks,项目名称:geoserver-shell,代码行数:24,代码来源:CoverageStoreCommands.java

示例15: listStyles

import org.springframework.shell.support.util.OsUtils; //导入依赖的package包/类
@CliCommand(value = "layer style list", help = "List the Styles for a layer.")
public String listStyles(
        @CliOption(key = "name", mandatory = true, help = "The name") String name
) throws Exception {
    String url = geoserver.getUrl() + "/rest/layers/" + URLUtil.encode(name) + "/styles.xml";
    String xml = HTTPUtils.get(url, geoserver.getUser(), geoserver.getPassword());
    Element element = JDOMBuilder.buildElement(xml);
    List<Element> styleElements = element.getChildren("style");
    List<String> names = new ArrayList<String>();
    for (Element styleElement : styleElements) {
        names.add(styleElement.getChildText("name"));
    }
    Collections.sort(names);
    StringBuilder builder = new StringBuilder();
    for (String nm : names) {
        builder.append(nm).append(OsUtils.LINE_SEPARATOR);
    }
    return builder.toString();
}
 
开发者ID:jericks,项目名称:geoserver-shell,代码行数:20,代码来源:LayerCommands.java


注:本文中的org.springframework.shell.support.util.OsUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。