我想在Java GUI中显示一个树,但我不知道如何.树表示连接节点的图形,如下所示:
![]()
我应该说我有自己的树类:
public class BinaryTree
{
private BinaryNode root;
public BinaryTree( )
{
root = null;
}
public BinaryTree( Object rootItem )
{
root = new BinaryNode( rootItem, null, null );
}
public BinaryTree( Object rootItem,BinaryNode a,BinaryNode b )
{
root = new BinaryNode( rootItem, a, b );
}
public int leavesCount(){
return BinaryNode.leavesCount(root);
}
public boolean equal(BinaryTree a,BinaryTree b){
return BinaryNode.equal(a.root, b.root);
}
public void printPreOrder( )
{
if( root != null )
root.printPreOrder( );
}
public void …Run Code Online (Sandbox Code Playgroud) 我正在开发一个显示HTML页面某些部分的Android应用程序.第一步,我使用此代码提供的代码如何从WebView检索HTML内容.
/* An instance of this class will be registered as a JavaScript interface */
class MyJavaScriptInterface
{
@SuppressWarnings("unused")
public void processHTML(String html)
{
// process the html as needed by the app
}
}
final WebView browser = (WebView)findViewById(R.id.browser);
/* JavaScript must be enabled if you want it to work, obviously */
browser.getSettings().setJavaScriptEnabled(true);
/* Register a new JavaScript interface called HTMLOUT */
browser.addJavascriptInterface(new MyJavaScriptInterface(), "HTMLOUT");
/* WebViewClient must be set BEFORE calling loadUrl! */
browser.setWebViewClient(new …Run Code Online (Sandbox Code Playgroud)我正在使用身份服务器4作为令牌服务的asp.net MVC应用程序.我有一个api,它有一些安全的资源.我想为api实现角色(授权).我想确保只有具有有效角色的授权资源才能访问api端点,否则会获得401(未经授权的错误).
这是我的配置:
客户
new Client()
{
ClientId = "mvcClient",
ClientName = "MVC Client",
AllowedGrantTypes = GrantTypes.HybridAndClientCredentials,
ClientSecrets = new List<Secret>()
{
new Secret("secret".Sha256())
},
RequireConsent = false;
// where to redirect to after login
RedirectUris = { "http://localhost:5002/signin-oidc" },
// where to redirect to after logout
PostLogoutRedirectUris = { "http://localhost:5002" },
AllowedScopes =
{
StandardScopes.OpenId.Name,
StandardScopes.Profile.Name,
StandardScopes.OfflineAccess.Name,
StandardScopes.Roles.Name,
"API"
}
}
Run Code Online (Sandbox Code Playgroud)
领域
return new List<Scope>()
{
StandardScopes.OpenId, // subject id
StandardScopes.Profile, // first name, last name
StandardScopes.OfflineAccess, // requesting …Run Code Online (Sandbox Code Playgroud) 我正在尝试解密.m3u8播放列表,我按照以下步骤操作:
my.key,并将其放在目录中。请注意,如果播放列表有多个键,则可以旋转键,将它们全部复制到不同的文件中。.ts段复制到同一目录playlist.m3u8并仅使用键 URI 和段的文件名。并使用此命令解密播放列表
ffmpeg -i playlist.m3u8 -c copy output.ts
Run Code Online (Sandbox Code Playgroud)
但我收到了这个错误:Invalid data found when processing input
这是我的 m3u8 :
#EXTM3U
#EXT-X-TARGETDURATION:12
#EXT-X-ALLOW-CACHE:YES
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-KEY:METHOD=AES-128,URI="my.key"
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:1
#EXTINF:6.000,
s-1-v1-a1.ts
#EXTINF:6.000,
s-2-v1-a1.ts
#EXTINF:6.000,
s-3-v1-a1.ts
#EXTINF:12.000,
s-4-v1-a1.ts
#EXTINF:12.000,
s-5-v1-a1.ts
#EXTINF:6.000,
s-6-v1-a1.ts
#EXT-X-ENDLIST
Run Code Online (Sandbox Code Playgroud)
.TS文件?我想单独解密文件我正在将IdentityServer4与.Net Core 2.1和Asp.Net Core标识一起使用。我的解决方案中有两个项目。
我想保护我的Web API,我使用邮差请求新的令牌,它可以正常工作并且令牌已成功生成。当我[Authorize]在没有角色的控制器上使用时 ,它可以完美工作,但是当我使用[Authorize(Roles="Student")](甚至与[Authorize(Policy="Student")])一起使用时 ,它总是返回403 forbidden
完整代码的Github链接:https : //github.com/Mohammad7070/ShagerdanehIdentityServer
我的代码有什么问题
Web API startup.cs
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvcCore()
.AddAuthorization(options => options.AddPolicy("Student", policy => policy.RequireClaim("Role", "Student")))
.AddAuthorization(options => options.AddPolicy("Teacher", policy => policy.RequireClaim("Role", …Run Code Online (Sandbox Code Playgroud) 我写了这个n-array树类现在我想编写一个方法来将一个子节点添加到我树中的特定节点,方法是:首先我应该搜索我的树找到父亲,然后将子节点添加到该节点.我不知道如何申报我的方法
public class FamilyNode {
public String name;
public String Family;
public String sex;
public FamilyNode Father;
public FamilyNode Mother;
public FamilyNode Spouse=null;
public String status="alive";
public int population;
public ArrayList<FamilyNode> children=new ArrayList<FamilyNode>() ;
public FamilyNode(String firstname,String lastname,String sex1){
this.name=firstname;
this.Family=lastname;
this.sex=sex1;
this.population=this.children.size()+1;
}
public void SetParents(FamilyNode father,FamilyNode mother){
this.Father=father;
this.Mother=mother;
}
public void SetHW(FamilyNode HW){
this.Spouse=HW;
}
public int Number (){
int number_of_descendants = this.population;
if(this.Spouse!=null) number_of_descendants++;
for(int index = 0; index < this.children.size(); index++)
number_of_descendants = number_of_descendants+ this.children.get(index).Number(); …Run Code Online (Sandbox Code Playgroud)